diff options
author | megamage <none@none> | 2009-02-12 17:09:15 -0600 |
---|---|---|
committer | megamage <none@none> | 2009-02-12 17:09:15 -0600 |
commit | 6aee5fcbe7473a3cbac12b7e8482a7b98bef8be3 (patch) | |
tree | 91ec91d5c19eba9c2fe0e84b1c9dc7047a3de80e /dep/include/zthread/LockedQueue.h | |
parent | 2d2f433b4de1c35b22aaf07854fc0ee11fcb350d (diff) | |
parent | f385747164c3fb278c92ef46fbd6c3da6590bbf0 (diff) |
*Merge.
--HG--
branch : trunk
Diffstat (limited to 'dep/include/zthread/LockedQueue.h')
-rw-r--r-- | dep/include/zthread/LockedQueue.h | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/dep/include/zthread/LockedQueue.h b/dep/include/zthread/LockedQueue.h index a1f0df26431..5aae3278406 100644 --- a/dep/include/zthread/LockedQueue.h +++ b/dep/include/zthread/LockedQueue.h @@ -36,7 +36,7 @@ namespace ZThread { * @date <2003-07-16T11:42:33-0400> * @version 2.3.0 * - * A LockedQueue is the simple Queue implementation that provides + * A LockedQueue is the simple Queue implementation that provides * serialized access to the values added to it. */ template <class T, class LockType, typename StorageType=std::deque<T> > @@ -65,7 +65,7 @@ namespace ZThread { virtual void add(const T& item) { Guard<LockType> g(_lock); - + if(_canceled) throw Cancellation_Exception(); @@ -77,18 +77,18 @@ namespace ZThread { * @see Queue::add(const T& item, unsigned long timeout) */ virtual bool add(const T& item, unsigned long timeout) { - + try { Guard<LockType> g(_lock, timeout); - + if(_canceled) throw Cancellation_Exception(); - + _queue.push_back(item); } catch(Timeout_Exception&) { return false; } - + return true; } @@ -97,23 +97,23 @@ namespace ZThread { * @see Queue::next() */ virtual T next() { - + Guard<LockType> g(_lock); if(_queue.empty() && _canceled) throw Cancellation_Exception(); - + if(_queue.empty()) throw NoSuchElement_Exception(); T item = _queue.front(); _queue.pop_front(); - + return item; } - + /** * @see Queue::next(unsigned long timeout) */ @@ -123,15 +123,15 @@ namespace ZThread { if(_queue.empty() && _canceled) throw Cancellation_Exception(); - + if(_queue.empty()) throw NoSuchElement_Exception(); T item = _queue.front(); _queue.pop_front(); - + return item; - + } virtual T front() @@ -148,7 +148,7 @@ namespace ZThread { * @see Queue::cancel() */ virtual void cancel() { - + Guard<LockType> g(_lock); _canceled = true; @@ -159,11 +159,11 @@ namespace ZThread { * @see Queue::isCanceled() */ virtual bool isCanceled() { - + // Faster check since the queue will not become un-canceled if(_canceled) return true; - + Guard<LockType> g(_lock); return _canceled; |