From e585187b248f48b3c6e9247b49fa07c6565d65e5 Mon Sep 17 00:00:00 2001 From: maximius Date: Sat, 17 Oct 2009 15:51:44 -0700 Subject: *Backed out changeset 3be01fb200a5 --HG-- branch : trunk --- src/shared/LockedQueue.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/shared/LockedQueue.h') diff --git a/src/shared/LockedQueue.h b/src/shared/LockedQueue.h index 7585989fdd0..6543487da81 100644 --- a/src/shared/LockedQueue.h +++ b/src/shared/LockedQueue.h @@ -15,13 +15,16 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #ifndef LOCKEDQUEUE_H #define LOCKEDQUEUE_H + #include #include #include #include #include "Errors.h" + namespace ACE_Based { template > @@ -29,41 +32,56 @@ namespace ACE_Based { //! Lock access to the queue. LockType _lock; + //! Storage backing the queue. StorageType _queue; + //! Cancellation flag. volatile bool _canceled; + public: + //! Create a LockedQueue. LockedQueue() : _canceled(false) {} + //! Destroy a LockedQueue. virtual ~LockedQueue() { } + //! Adds an item to the queue. void add(const T& item) { ACE_Guard g(this->_lock); + //ASSERT(!this->_canceled); // throw Cancellation_Exception(); + _queue.push_back(item); } + //! Gets the next result in the queue, if any. bool next(T& result) { ACE_Guard g(this->_lock); + if (_queue.empty()) return false; + //ASSERT (!_queue.empty() || !this->_canceled); // throw Cancellation_Exception(); result = _queue.front(); _queue.pop_front(); + return true; } + //! Cancels the queue. void cancel() { ACE_Guard g(this->_lock); + _canceled = true; } + //! Checks if the queue is cancelled. bool cancelled() { -- cgit v1.2.3