Main Page   Namespace List   Class Hierarchy   Compound List   Compound Members  

ZThread::LockedQueue Class Template Reference

#include <LockedQueue.h>

Inheritance diagram for ZThread::LockedQueue::

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

Public Methods

 LockedQueue ()
virtual ~LockedQueue () throw ()
virtual void add (T item) throw (Synchronization_Exception)
virtual T next () throw (Synchronization_Exception)
virtual T next (unsigned long timeout) throw (Synchronization_Exception)
virtual void cancel () throw (Synchronization_Exception)
virtual bool isCanceled () throw (Synchronization_Exception)
virtual bool empty () throw (Synchronization_Exception)

Protected Attributes

LOCK _lock
 Serialize access.

std::deque<T> _data
 Backing deque.

bool _canceled
 Cancellation flag.


Detailed Description

template<class T, class LOCK = Mutex> class ZThread::LockedQueue

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

A LockedQueue is the simplest thread safe queue. All its methods are guarded with a mutex.


Constructor & Destructor Documentation

LockedQueue ( ) [inline]
 

Create a new LockedQueue

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

Destroy the Queue


Member Function Documentation

void add ( T item ) throw (Synchronization_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 (Synchronization_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 (Synchronization_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 (Synchronization_Exception) [inline, virtual]
 

Check the cancelation status of this Queue

Returns:
bool - Queue cancled

Reimplemented from ZThread::Cancelable.

T next ( unsigned long timeout ) throw (Synchronization_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 been canceled.
Timeout_Exception   - thrown if the given amount of time has expired and the queue could not return an item
NoSuchElement_Exception   - thrown if the queue is empty
Parameters:
timeout  

Reimplemented from ZThread::Queue.

T next ( ) throw (Synchronization_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.
NoSuchElement_Exception   - thrown if the queue is empty

Reimplemented from ZThread::Queue.


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