diff options
author | Alan Conway <aconway@apache.org> | 2008-11-06 17:23:30 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2008-11-06 17:23:30 +0000 |
commit | bb57351c81b5f28133dbef8251f56911e215b339 (patch) | |
tree | df4d31860cfa84cb92782a1c3a0d12bd4937a176 | |
parent | d8cda3197b53140ce4c8d0a0141e3962eb37a391 (diff) | |
download | qpid-python-bb57351c81b5f28133dbef8251f56911e215b339.tar.gz |
Correct excessive use of inline functions in PersistableMessage.h.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@711915 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | qpid/cpp/src/qpid/broker/PersistableMessage.cpp | 106 | ||||
-rw-r--r-- | qpid/cpp/src/qpid/broker/PersistableMessage.h | 125 |
2 files changed, 133 insertions, 98 deletions
diff --git a/qpid/cpp/src/qpid/broker/PersistableMessage.cpp b/qpid/cpp/src/qpid/broker/PersistableMessage.cpp index 3bf390faf3..b67a669f1d 100644 --- a/qpid/cpp/src/qpid/broker/PersistableMessage.cpp +++ b/qpid/cpp/src/qpid/broker/PersistableMessage.cpp @@ -26,6 +26,20 @@ using namespace qpid::broker; +namespace qpid { +namespace broker { + +class MessageStore; + +PersistableMessage::~PersistableMessage() {} + +PersistableMessage::PersistableMessage() : + asyncEnqueueCounter(0), + asyncDequeueCounter(0), + contentReleased(false), + store(0) +{} + void PersistableMessage::flush() { syncList copy; @@ -45,4 +59,96 @@ void PersistableMessage::flush() } } +void PersistableMessage::setContentReleased() {contentReleased = true; } + +bool PersistableMessage::isContentReleased()const { return contentReleased; } + +void PersistableMessage::waitForEnqueueComplete() { + sys::ScopedLock<sys::Monitor> l(asyncEnqueueLock); + while (asyncEnqueueCounter > 0) { + asyncEnqueueLock.wait(); + } +} + +bool PersistableMessage::isEnqueueComplete() { + sys::ScopedLock<sys::Monitor> l(asyncEnqueueLock); + return asyncEnqueueCounter == 0; +} + +void PersistableMessage::enqueueComplete() { + bool notify = false; + { + sys::ScopedLock<sys::Monitor> l(asyncEnqueueLock); + if (asyncEnqueueCounter > 0) { + if (--asyncEnqueueCounter == 0) { + asyncEnqueueLock.notify(); + notify = true; + } + } + } + if (notify) { + sys::ScopedLock<sys::Mutex> l(storeLock); + if (store) { + for (syncList::iterator i = synclist.begin(); i != synclist.end(); ++i) { + PersistableQueue::shared_ptr q(i->lock()); + if (q) q->notifyDurableIOComplete(); + } + } + } +} + +void PersistableMessage::enqueueAsync(PersistableQueue::shared_ptr queue, MessageStore* _store) { + if (_store){ + sys::ScopedLock<sys::Mutex> l(storeLock); + store = _store; + boost::weak_ptr<PersistableQueue> q(queue); + synclist.push_back(q); + } + enqueueAsync(); +} + +void PersistableMessage::enqueueAsync() { + sys::ScopedLock<sys::Monitor> l(asyncEnqueueLock); + asyncEnqueueCounter++; +} + +bool PersistableMessage::isDequeueComplete() { + sys::ScopedLock<sys::Monitor> l(asyncDequeueLock); + return asyncDequeueCounter == 0; +} +void PersistableMessage::dequeueComplete() { + + sys::ScopedLock<sys::Monitor> l(asyncDequeueLock); + if (asyncDequeueCounter > 0) { + if (--asyncDequeueCounter == 0) { + asyncDequeueLock.notify(); + } + } +} + +void PersistableMessage::waitForDequeueComplete() { + sys::ScopedLock<sys::Monitor> l(asyncDequeueLock); + while (asyncDequeueCounter > 0) { + asyncDequeueLock.wait(); + } +} + +void PersistableMessage::dequeueAsync(PersistableQueue::shared_ptr queue, MessageStore* _store) { + if (_store){ + sys::ScopedLock<sys::Mutex> l(storeLock); + store = _store; + boost::weak_ptr<PersistableQueue> q(queue); + synclist.push_back(q); + } + dequeueAsync(); +} + +void PersistableMessage::dequeueAsync() { + sys::ScopedLock<sys::Monitor> l(asyncDequeueLock); + asyncDequeueCounter++; +} + +}} + + diff --git a/qpid/cpp/src/qpid/broker/PersistableMessage.h b/qpid/cpp/src/qpid/broker/PersistableMessage.h index 7ed54c0ff0..6b6e9a7007 100644 --- a/qpid/cpp/src/qpid/broker/PersistableMessage.h +++ b/qpid/cpp/src/qpid/broker/PersistableMessage.h @@ -41,6 +41,7 @@ class MessageStore; */ class PersistableMessage : public Persistable { + typedef std::list< boost::weak_ptr<PersistableQueue> > syncList; sys::Monitor asyncEnqueueLock; sys::Monitor asyncDequeueLock; sys::Mutex storeLock; @@ -62,15 +63,16 @@ class PersistableMessage : public Persistable * dequeues. */ int asyncDequeueCounter; -protected: - typedef std::list< boost::weak_ptr<PersistableQueue> > syncList; + + bool contentReleased; syncList synclist; + + protected: MessageStore* store; - bool contentReleased; - inline void setContentReleased() {contentReleased = true; } + void setContentReleased(); -public: + public: typedef boost::shared_ptr<PersistableMessage> shared_ptr; /** @@ -78,106 +80,33 @@ public: */ virtual uint32_t encodedHeaderSize() const = 0; - virtual ~PersistableMessage() {}; + virtual ~PersistableMessage(); - PersistableMessage(): - asyncEnqueueCounter(0), - asyncDequeueCounter(0), - store(0), - contentReleased(false) - {} + PersistableMessage(); void flush(); - inline bool isContentReleased()const {return contentReleased; } + bool isContentReleased() const; - inline void waitForEnqueueComplete() { - sys::ScopedLock<sys::Monitor> l(asyncEnqueueLock); - while (asyncEnqueueCounter > 0) { - asyncEnqueueLock.wait(); - } - } - - inline bool isEnqueueComplete() { - sys::ScopedLock<sys::Monitor> l(asyncEnqueueLock); - return asyncEnqueueCounter == 0; - } - - inline void enqueueComplete() { - bool notify = false; - { - sys::ScopedLock<sys::Monitor> l(asyncEnqueueLock); - if (asyncEnqueueCounter > 0) { - if (--asyncEnqueueCounter == 0) { - asyncEnqueueLock.notify(); - notify = true; - } - } - } - if (notify) { - sys::ScopedLock<sys::Mutex> l(storeLock); - if (store) { - for (syncList::iterator i = synclist.begin(); i != synclist.end(); ++i) { - PersistableQueue::shared_ptr q(i->lock()); - if (q) q->notifyDurableIOComplete(); - } - } - } - } - - inline void enqueueAsync(PersistableQueue::shared_ptr queue, MessageStore* _store) { - if (_store){ - sys::ScopedLock<sys::Mutex> l(storeLock); - store = _store; - boost::weak_ptr<PersistableQueue> q(queue); - synclist.push_back(q); - } - enqueueAsync(); - } - - inline void enqueueAsync() { - sys::ScopedLock<sys::Monitor> l(asyncEnqueueLock); - asyncEnqueueCounter++; - } - - inline bool isDequeueComplete() { - sys::ScopedLock<sys::Monitor> l(asyncDequeueLock); - return asyncDequeueCounter == 0; - } - - inline void dequeueComplete() { - - sys::ScopedLock<sys::Monitor> l(asyncDequeueLock); - if (asyncDequeueCounter > 0) { - if (--asyncDequeueCounter == 0) { - asyncDequeueLock.notify(); - } - } - } - - inline void waitForDequeueComplete() { - sys::ScopedLock<sys::Monitor> l(asyncDequeueLock); - while (asyncDequeueCounter > 0) { - asyncDequeueLock.wait(); - } - } - - inline void dequeueAsync(PersistableQueue::shared_ptr queue, MessageStore* _store) { - if (_store){ - sys::ScopedLock<sys::Mutex> l(storeLock); - store = _store; - boost::weak_ptr<PersistableQueue> q(queue); - synclist.push_back(q); - } - dequeueAsync(); - } - - inline void dequeueAsync() { - sys::ScopedLock<sys::Monitor> l(asyncDequeueLock); - asyncDequeueCounter++; - } + void waitForEnqueueComplete(); + bool isEnqueueComplete(); + + void enqueueComplete(); + + void enqueueAsync(PersistableQueue::shared_ptr queue, MessageStore* _store); + + void enqueueAsync(); + + bool isDequeueComplete(); + void dequeueComplete(); + + void waitForDequeueComplete(); + + void dequeueAsync(PersistableQueue::shared_ptr queue, MessageStore* _store); + + void dequeueAsync(); }; }} |