Main Page   Namespace List   Class Hierarchy   Compound List   Namespace Members   Compound Members  

BlockingQueue Class Template Reference

#include <BlockingQueue.h>

Inheritance diagram for BlockingQueue:

Queue Cancelable NonCopyable List of all members.

Public Methods

 BlockingQueue ()
 Create a new BlockingQueue.

virtual ~BlockingQueue () throw ()
 Destroy this BlockingQueue, delete remaining items.

virtual void add (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)

Detailed Description

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

Author:
Eric Crahen <crahen@cse.buffalo.edu>
Date:
<2002-06-29T07:52:35-0700>
Version:
2.2.8
Like a LockedQueue, a BlockingQueue is a Queue implementation that provides serialized access to the items added to it. It differs by causing threads causing the next() methods to block until an item becomes available.


Member Function Documentation

virtual bool add   item,
unsigned long    timeout
[inline, virtual]
 

Adds an object to this Queue.

This method will block the calling thread until exclusive access to the Queue can be obtained, until an exception is thrown or until the given amount of time expires.

Parameters:
item  - object to attempt to add to this Queue
timeout  - maximum amount of time (milliseconds) this method could block
Returns :
true if the item was add()ed before the given timeout expired. Otherwise false
See also:
Queue::add(T, unsigned long)
Postcondition:
if the Queue was empty, threads blocked by a next() method will be awakend if no exception is thrown and the method returns true

Implements Queue.

virtual void add   item [inline, virtual]
 

Adds an object to this Queue.

This method will block the calling thread until exclusive access to the Queue can be obtained or until an exception is thrown.

Parameters:
item  - object to attempt to add to this Queue
See also:
Queue::add(T)
Postcondition:
if the Queue was empty, threads blocked by a next() method will be awakend if no exception is thrown

Implements Queue.

virtual void cancel   [inline, virtual]
 

Cancel this queue.

This method will block the calling thread until exclusive access to the Queue can be obtained or until an exception is thrown.

See also:
Queue::cancel()
Postcondition:
If threads are blocked on a next(), empty() or size() method, they will awakend

Implements Queue.

virtual bool isCanceled   [inline, virtual]
 

Determine if this Queue has been cancel()ed.

This method will block the calling thread until exclusive access to the Queue can be obtained or until an exception is thrown.

Returns :
bool true if cancel() was called prior to this method, otherwise false.
See also:
Queue::isCanceled()

Implements Cancelable.

virtual T next unsigned long    timeout [inline, virtual]
 

Get an object from this Queue.

This method will block the calling thread until an item arrives in the Queue or until an exception is thrown.

Parameters:
timeout  - maximum amount of time (milliseconds) this method could block
Returns :
T next available object
See also:
Queue::next(unsigned long)
Exceptions:
Cancellation_Exception  thrown if there are no items available in the Queue and the Queue has become cancel()ed
Postcondition:
if the Queue becomes empty as a result of this method, threads blocked by an empty() or size() method will be awakend.

Implements Queue.

virtual T next   [inline, virtual]
 

Get an object from this Queue.

This method will block the calling thread until an item arrives in the Queue or until an exception is thrown.

Returns :
T next available object
See also:
Queue::next()
Exceptions:
Cancellation_Exception  thrown if there are no items available in the Queue and the Queue has become cancel()ed
Postcondition:
if the Queue becomes empty as a result of this method, threads blocked by an empty() or size() method will be awakend.

Implements Queue.

virtual size_t size unsigned long    timeout [inline, virtual]
 

Count the items present in this Queue.

This method will not block the calling thread.

Returns :
size_t number of elements available in the Queue. These are retrievable through the next() methods.
See also:
Queue::size(unsigned long)

Implements Queue.

virtual size_t size   [inline, virtual]
 

Count the items present in this Queue.

This method will not block the calling thread.

Returns :
size_t number of elements available in the Queue. These are retrievable through the next() methods.
See also:
Queue::size()

Implements Queue.


The documentation for this class was generated from the following file:
Generated on Tue Aug 27 07:43:10 2002 for ZThread by doxygen1.2.17