Main Page   Namespace List   Class Hierarchy   Compound List   Compound Members  

ZThread::BlockingQueue Class Template Reference

#include <BlockingQueue.h>

Inheritance diagram for ZThread::BlockingQueue::

ZThread::Queue ZThread::Cancelable List of all members.

Public Methods

 BlockingQueue () throw ()
virtual ~BlockingQueue () throw ()
virtual void add (T item) throw (Interrupted_Exception, Cancelation_Exception)
virtual T next () throw (Interrupted_Exception, Cancelation_Exception)
virtual T next (unsigned long timeout) throw (Interrupted_Exception, Cancelation_Exception, Timeout_Exception)
virtual void cancel () throw (Interrupted_Exception)
virtual bool isCanceled () throw (Interrupted_Exception)
virtual bool empty () throw (Interrupted_Exception)

Protected Attributes

Condition _notEmpty
 Signaled when empty.

Mutex _lock
 Serialize access.

std::deque<T> _data
 Item queue.

bool _canceled
 Cancellation flag.


Detailed Description

template<class T> class ZThread::BlockingQueue

Date:
04-12-2001
Author:
Eric Crahen
Version:
1.3.4

This is a slightly more useful queue than the LockedQueue. It's methods are guarded, and it will block threads trying to withdraw an item from an empty queue.


Constructor & Destructor Documentation

BlockingQueue ( ) throw () [inline]
 

Create a new BlockingQueue

~BlockingQueue ( ) throw () [inline, virtual]
 

Destroy this Queue


Member Function Documentation

void add ( T item ) throw (Interrupted_Exception, Cancelation_Exception) [inline, virtual]
 

Add a new object to this Queue

Parameters:
T   object to add
Exceptions:
InterruptedException  
CancelationException   - the queue has been canceled.
Parameters:
item  

Reimplemented from ZThread::Queue.

void cancel ( ) throw (Interrupted_Exception) [inline, virtual]
 

Cancel this queue. No more objects can be added to it

Exceptions:
InterruptedException  

Postcondition:
- The next() method will continue to return objects until the queue has been emptied. After the queue is emptied, further calls to next() will throw CancelationException

The add() method will begin to throw CancelationException and no item will be accepted by this queue

Reimplemented from ZThread::Queue.

bool empty ( ) throw (Interrupted_Exception) [inline, virtual]
 

Test this queue to see if it is empty. This method may or may not block the caller, it is completely up to the implementation to decide weather or not it is appropriate to block the caller.

Returns:
boolean - true if empty
Exceptions:
InterruptedException  

Reimplemented from ZThread::Queue.

bool isCanceled ( ) throw (Interrupted_Exception) [inline, virtual]
 

Check the cancelation status of this Queue

Returns:
bool - Queue cancled

Reimplemented from ZThread::Cancelable.

T next ( unsigned long timeout ) throw (Interrupted_Exception, Cancelation_Exception, Timeout_Exception) [inline, virtual]
 

Get an object from this Queue within a given amount of time

Parameters:
unsigned   long time limit

Returns:
T next available object
Exceptions:
InterruptedException  
CancelationException   - the queue is empty and has
Timeout_Exception   - thrown if the given amount of time has expired and the queue could not return an item been canceled.
Parameters:
timeout  

Reimplemented from ZThread::Queue.

T next ( ) throw (Interrupted_Exception, Cancelation_Exception) [inline, virtual]
 

Get an object from this Queue

Returns:
T next available object
Exceptions:
InterruptedException  
CancelationException   - the queue is empty and has been canceled.

Reimplemented from ZThread::Queue.


The documentation for this class was generated from the following file:
Generated at Fri Aug 31 09:07:59 2001 for ZThread by doxygen1.2.8 written by Dimitri van Heesch, © 1997-2001