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

Queue Class Template Reference

#include <Queue.h>

Inheritance diagram for Queue:

Cancelable NonCopyable BlockingQueue BoundedQueue LockedQueue MonitoredQueue List of all members.

Public Methods

virtual ~Queue () throw ()
 Destroy a Queue.

virtual void add (T item)=0
virtual bool add (T item, unsigned long timeout)=0
virtual T next ()=0
virtual T next (unsigned long timeout)=0
virtual void cancel ()=0
virtual size_t size ()=0
virtual size_t size (unsigned long timeout)=0
virtual bool empty ()
virtual bool empty (unsigned long timeout)

Detailed Description

template<class T>
class ZThread::Queue< T >

Author:
Eric Crahen <crahen@cse.buffalo.edu>
Date:
<2002-06-01T17:37:24-0400>
Version:
2.2.0
A Queue defines an interface of a synchronization point for a collection objects. It also defines the semantics for how the ownership of these objects is transfered between the Queue and the objects that interact with it.

A Queue coordinates the gathering and distribution of items for any set of threads.


Member Function Documentation

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

Add an object to this Queue, tranfering the ownership of that object to the Queue. As the new owner, the Queue becomes responsible for deleting the add()ed 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:
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
Exceptions:
Cancellation_Exception  thrown if an item is added to a cancel()ed Queue
Interrupted_Exception  thrown if the the method is invoked from the context of a thread that has been interrupt()ed.
Synchronization_Exception  thrown if there is some other error in adding the item to the Queue

Implemented in BlockingQueue, BoundedQueue, LockedQueue, and MonitoredQueue.

virtual void add   item [pure virtual]
 

Add an object to this Queue, tranfering the ownership of that object to the Queue. As the new owner, the Queue becomes responsible for deleting the add()ed 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.

Parameters:
item  - object to attempt to add to this Queue
Exceptions:
Cancellation_Exception  thrown if an item is added to a cancel()ed Queue
Interrupted_Exception  thrown if the the method is invoked from the context of a thread that has been interrupt()ed.
Synchronization_Exception  thrown if there is some other error in adding the item to the Queue

Implemented in BlockingQueue, BoundedQueue, LockedQueue, and MonitoredQueue.

virtual void cancel   [pure virtual]
 

Canceling a Queue disables it, disallowing further add()itions. Items already present in the Queue can still be retrieved and are still available through the next() methods.

cancel()ing a Queue more than once has no effect.

Postcondition:
The next() methods will continue to return objects until the Queue has been emptied. At that point, further calls to the next() methods will throw Cancellation_Exceptions
Postcondition:
The add() methods will throw Cancellation_Exceptions from this point on.
Exceptions:
Interrupted_Exception  should not be thrown.
Synchronization_Exception  thrown if there is some error in cancel()ing the Queue.

Implements Cancelable.

Implemented in BlockingQueue, BoundedQueue, LockedQueue, and MonitoredQueue.

virtual bool empty unsigned long    timeout [inline, virtual]
 

Test this Queue to see if it is empty by testing the size of the Queue.

Parameters:
timeout  - maximum amount of time (millseconds) this method could block
Returns :
boolean true if empty, otherwise false
Exceptions:
Cancellation_Exception  should not be thrown. A cancel()ed Queue that contains no more elements should report that it is empty.
See also:
Queue::size(unsigned long)

Reimplemented in BoundedQueue, and MonitoredQueue.

virtual bool empty   [inline, virtual]
 

Test this Queue to see if it is empty by testing the size of the Queue.

Returns :
boolean true if empty, otherwise false
Exceptions:
Cancellation_Exception  should not be thrown. A cancel()ed Queue that contains no more elements should report that it is empty.
See also:
Queue::size()

Reimplemented in BoundedQueue, and MonitoredQueue.

virtual T next unsigned long    timeout [pure virtual]
 

Get an object from this Queue, transfering the ownership of that object to the caller. As the new owner, the caller becomes responsible for deleting the 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 (millseconds) this method could block
Returns :
T next available object
Exceptions:
Cancellation_Exception  thrown if the Queue has been cancel()ed and no more items are present.
Interrupted_Exception  thrown if the the method is invoked from the context of a thread that has been interrupt()ed.
Timeout_Exception  thrown if the given amount of time has expired before an item becomes available
Synchronization_Exception  thrown if there is some other error in adding the item to the Queue

Implemented in BlockingQueue, BoundedQueue, LockedQueue, and MonitoredQueue.

virtual T next   [pure virtual]
 

Get an object from this Queue, transfering the ownership of that object to the caller. As the new owner, the caller becomes responsible for deleting the 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.

Returns :
T next available object
Exceptions:
Cancellation_Exception  thrown if the Queue has been cancel()ed and no more items are present.
Interrupted_Exception  thrown if the the method is invoked from the context of a thread that has been interrupt()ed.
Synchronization_Exception  thrown if there is some other error in adding the item to the Queue

Implemented in BlockingQueue, BoundedQueue, LockedQueue, and MonitoredQueue.

virtual size_t size unsigned long    timeout [pure virtual]
 

Count the items present in this Queue.

This method may or may not block the caller for an indefinite amount of time. Those details are defined by specializations of this class.

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 (millseconds) this method could block
Returns :
size_t number of elements available in the Queue. These are retrievable through the next() methods.
Exceptions:
Interrupted_Exception  thrown if the the method is invoked from the context of a thread that has been interrupt()ed.
Timeout_Exception  thrown if the given amount of time has expired before an item becomes available
Synchronization_Exception  thrown if there is some error in counting the items.

Implemented in BlockingQueue, BoundedQueue, LockedQueue, and MonitoredQueue.

virtual size_t size   [pure virtual]
 

Count the items present in this Queue.

This method may or may not block the caller for an indefinite amount of time. Those details are defined by specializations of this class.

Returns :
size_t number of elements available in the Queue. These are retrievable through the next() methods.
Exceptions:
Interrupted_Exception  thrown if the the method is invoked from the context of a thread that has been interrupt()ed.
Synchronization_Exception  thrown if there is some error in counting the items.

Implemented in BlockingQueue, BoundedQueue, LockedQueue, and MonitoredQueue.


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