#include <BoundedQueue.h>
Inheritance diagram for ZThread::BoundedQueue< T, LockType, StorageType >:
Public Member Functions | |
BoundedQueue (size_t capacity) | |
virtual | ~BoundedQueue () |
Destroy this Queue. | |
size_t | capacity () |
virtual void | add (const T &item) |
virtual bool | add (const T &item, unsigned long timeout) |
virtual T | next () |
virtual T | next (unsigned long timeout) |
virtual void | cancel () |
virtual bool | isCanceled () |
virtual size_t | size () |
virtual size_t | size (unsigned long timeout) |
virtual bool | empty () |
virtual bool | empty (unsigned long timeout) |
virtual void | acquire () |
virtual bool | tryAcquire (unsigned long timeout) |
virtual void | release () |
ZThread::BoundedQueue< T, LockType, StorageType >::BoundedQueue | ( | size_t | capacity | ) | [inline] |
Create a BoundedQueue with the given capacity.
capacity | maximum number of values to allow in the Queue at at any time |
virtual void ZThread::BoundedQueue< T, LockType, StorageType >::acquire | ( | ) | [inline, virtual] |
Acquire the Lockable object.
This method may or may not block the caller for an indefinite amount of time. Those details are defined by specializations of this class.
Interrupted_Exception | thrown if the calling thread is interrupted before the operation completes. |
Implements ZThread::Lockable.
virtual bool ZThread::BoundedQueue< T, LockType, StorageType >::add | ( | const T & | item, | |
unsigned long | timeout | |||
) | [inline, virtual] |
Add a value to this Queue.
If the number of values in the queue matches the value returned by capacity() then the calling thread will be blocked until at least one value is removed from the Queue.
item | value to be added to the Queue | |
timeout | maximum amount of time (milliseconds) this method may block the calling thread. |
Cancellation_Exception | thrown if this Queue has been canceled. | |
Interrupted_Exception | thrown if the thread was interrupted while waiting to add a value |
Implements ZThread::Queue< T >.
virtual void ZThread::BoundedQueue< T, LockType, StorageType >::add | ( | const T & | item | ) | [inline, virtual] |
Add a value to this Queue.
If the number of values in the queue matches the value returned by capacity() then the calling thread will be blocked until at least one value is removed from the Queue.
item | value to be added to the Queue |
Cancellation_Exception | thrown if this Queue has been canceled. | |
Interrupted_Exception | thrown if the thread was interrupted while waiting to add a value |
Implements ZThread::Queue< T >.
virtual void ZThread::BoundedQueue< T, LockType, StorageType >::cancel | ( | ) | [inline, virtual] |
Cancel this queue.
Any threads blocked by a next() function will throw a Cancellation_Exception.
Implements ZThread::Queue< T >.
size_t ZThread::BoundedQueue< T, LockType, StorageType >::capacity | ( | ) | [inline] |
virtual bool ZThread::BoundedQueue< T, LockType, StorageType >::empty | ( | unsigned long | timeout | ) | [inline, virtual] |
Test whether any values are available in this Queue.
The calling thread is blocked until there are no values present in the Queue.
timeout | maximum amount of time (milliseconds) this method may block the calling thread. |
Timeout_Exception | thrown if timeout milliseconds expire before a value becomes available |
Reimplemented from ZThread::Queue< T >.
virtual bool ZThread::BoundedQueue< T, LockType, StorageType >::empty | ( | ) | [inline, virtual] |
Test whether any values are available in this Queue.
The calling thread is blocked until there are no values present in the Queue.
Reimplemented from ZThread::Queue< T >.
virtual bool ZThread::BoundedQueue< T, LockType, StorageType >::isCanceled | ( | ) | [inline, virtual] |
virtual T ZThread::BoundedQueue< T, LockType, StorageType >::next | ( | unsigned long | timeout | ) | [inline, virtual] |
Retrieve and remove a value from this Queue.
If invoked when there are no values present to return then the calling thread will be blocked until a value arrives in the Queue.
timeout | maximum amount of time (milliseconds) this method may block the calling thread. |
Cancellation_Exception | thrown if this Queue has been canceled. | |
Timeout_Exception | thrown if the timeout expires before a value can be retrieved. |
Implements ZThread::Queue< T >.
virtual T ZThread::BoundedQueue< T, LockType, StorageType >::next | ( | ) | [inline, virtual] |
Retrieve and remove a value from this Queue.
If invoked when there are no values present to return then the calling thread will be blocked until a value arrives in the Queue.
Cancellation_Exception | thrown if this Queue has been canceled. | |
Interrupted_Exception | thrown if the thread was interrupted while waiting to retrieve a value |
Implements ZThread::Queue< T >.
virtual void ZThread::BoundedQueue< T, LockType, StorageType >::release | ( | ) | [inline, virtual] |
Release the Lockable object.
This method may or may not block the caller for an indefinite amount of time. Those details are defined by specializations of this class.
Implements ZThread::Lockable.
virtual size_t ZThread::BoundedQueue< T, LockType, StorageType >::size | ( | unsigned long | timeout | ) | [inline, virtual] |
virtual size_t ZThread::BoundedQueue< T, LockType, StorageType >::size | ( | ) | [inline, virtual] |
virtual bool ZThread::BoundedQueue< T, LockType, StorageType >::tryAcquire | ( | unsigned long | timeout | ) | [inline, virtual] |
Attempt to acquire the Lockable object.
This method may or may not block the caller for a definite amount of time. Those details are defined by specializations of this class; however, this method includes a timeout value that can be used to limit the maximum amount of time that a specialization could block.
timeout | - maximum amount of time (milliseconds) this method could block |
Interrupted_Exception | thrown if the calling thread is interrupted before the operation completes. |
Implements ZThread::Lockable.