ZThread::BlockingQueue< T, LockType, StorageType > Class Template Reference

#include <BlockingQueue.h>

Inheritance diagram for ZThread::BlockingQueue< T, LockType, StorageType >:

ZThread::Queue< T > ZThread::Lockable ZThread::Cancelable ZThread::NonCopyable List of all members.

Public Member Functions

 BlockingQueue ()
 Create a new BlockingQueue.
virtual ~BlockingQueue ()
 Destroy this BlockingQueue.
virtual void add (const T &item)
virtual bool add (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 void acquire ()
virtual bool tryAcquire (unsigned long timeout)
virtual void release ()

Detailed Description

template<class T, class LockType, typename StorageType = std::deque<T>>
class ZThread::BlockingQueue< T, LockType, StorageType >

Author:
Eric Crahen <http://www.code-foo.com>
Date:
<2003-07-16T12:01:43-0400>
Version:
2.3.0
Like a LockedQueue, a BlockingQueue is a Queue implementation that provides serialized access to the items added to it. It differs by causing threads accessing the next() methods to block until a value becomes available.


Member Function Documentation

template<class T, class LockType, typename StorageType = std::deque<T>>
virtual void ZThread::BlockingQueue< 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.

Exceptions:
Interrupted_Exception thrown if the calling thread is interrupted before the operation completes.
Postcondition:
The Lockable is acquired only if no exception was thrown.

Implements ZThread::Lockable.

template<class T, class LockType, typename StorageType = std::deque<T>>
virtual bool ZThread::BlockingQueue< T, LockType, StorageType >::add ( item,
unsigned long  timeout 
) [inline, virtual]

See also:
Queue::add(const T& item, unsigned long timeout)

template<class T, class LockType, typename StorageType = std::deque<T>>
virtual void ZThread::BlockingQueue< T, LockType, StorageType >::add ( const T &  item  )  [inline, virtual]

See also:
Queue::add(const T& item)

Implements ZThread::Queue< T >.

template<class T, class LockType, typename StorageType = std::deque<T>>
virtual void ZThread::BlockingQueue< T, LockType, StorageType >::cancel (  )  [inline, virtual]

See also:
Queue::cancel()
Postcondition:
If threads are blocked on one of the next() functions then they will be awakened with a Cancellation_Exception.

Implements ZThread::Queue< T >.

template<class T, class LockType, typename StorageType = std::deque<T>>
virtual bool ZThread::BlockingQueue< T, LockType, StorageType >::isCanceled (  )  [inline, virtual]

See also:
Queue::isCanceled()

Implements ZThread::Cancelable.

template<class T, class LockType, typename StorageType = std::deque<T>>
virtual T ZThread::BlockingQueue< T, LockType, StorageType >::next ( unsigned long  timeout  )  [inline, virtual]

Get a value from this Queue. The calling thread may block indefinitely.

Parameters:
timeout maximum amount of time (milliseconds) this method may block the calling thread.
Returns:
T next available value
Exceptions:
Cancellation_Exception thrown if this Queue has been canceled.
Timeout_Exception thrown if the timeout expires before a value can be retrieved.
Interrupted_Exception thrown if the calling thread is interrupted before a value becomes available.
Precondition:
The Queue should not have been canceled prior to the invocation of this function.
Postcondition:
The value returned will have been removed from the Queue.
See also:
Queue::next(unsigned long timeout)

Implements ZThread::Queue< T >.

template<class T, class LockType, typename StorageType = std::deque<T>>
virtual T ZThread::BlockingQueue< T, LockType, StorageType >::next (  )  [inline, virtual]

Get a value from this Queue. The calling thread may block indefinitely.

Returns:
T next available value
Exceptions:
Cancellation_Exception thrown if this Queue has been canceled.
Interrupted_Exception thrown if the calling thread is interrupted before a value becomes available.
Precondition:
The Queue should not have been canceled prior to the invocation of this function.
Postcondition:
The value returned will have been removed from the Queue.
See also:
Queue::next()

Implements ZThread::Queue< T >.

template<class T, class LockType, typename StorageType = std::deque<T>>
virtual void ZThread::BlockingQueue< 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.

Postcondition:
The Lockable is released only if no exception was thrown.

Implements ZThread::Lockable.

template<class T, class LockType, typename StorageType = std::deque<T>>
virtual size_t ZThread::BlockingQueue< T, LockType, StorageType >::size ( unsigned long  timeout  )  [inline, virtual]

See also:
Queue::size(unsigned long timeout)

Implements ZThread::Queue< T >.

template<class T, class LockType, typename StorageType = std::deque<T>>
virtual size_t ZThread::BlockingQueue< T, LockType, StorageType >::size (  )  [inline, virtual]

See also:
Queue::size()

Implements ZThread::Queue< T >.

template<class T, class LockType, typename StorageType = std::deque<T>>
virtual bool ZThread::BlockingQueue< 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.

Parameters:
timeout - maximum amount of time (milliseconds) this method could block
Returns:
  • true if the operation completes and the Lockable is acquired before the timeout expires.
  • false if the operation times out before the Lockable can be acquired.
Exceptions:
Interrupted_Exception thrown if the calling thread is interrupted before the operation completes.
Postcondition:
The Lockable is acquired only if no exception was thrown.

Implements ZThread::Lockable.


The documentation for this class was generated from the following file:
Generated on Wed Aug 30 03:27:47 2006 for SWG EMU by  doxygen 1.4.7