If you can read this text, it means you are not experiencing this website at its best. This website is designed for used with a standards-compliant browser.
Current version: 2.3.2
ZThreads
A platform-independent, multi-threading and synchronization library for C++
Home Documentation Downloads CVS Contact
Queue< T > Class Template Referenceabstract

#include <Queue.h>

Inheritance diagram for Queue< T >:
Cancelable NonCopyable BlockingQueue< T, LockType, StorageType > BoundedQueue< T, LockType, StorageType > LockedQueue< T, LockType, StorageType > MonitoredQueue< T, LockType, StorageType >

Public Member Functions

virtual ~Queue ()
 Destroy a Queue.
 
virtual void add (const T &item)=0
 
virtual bool add (const 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)
 
- Public Member Functions inherited from Cancelable
virtual ~Cancelable ()
 Destroy a Cancelable object.
 
virtual void cancel ()=0
 
virtual bool isCanceled ()=0
 

Detailed Description

template<typename T>
class ZThread::Queue< T >
Author
Eric Crahen http://www.code-foo.com
Date
<2003-07-16T11:32:42-0400>
Version
2.3.0

A Queue defines an interface for a value-oriented collection objects (similar to STL collections).

Member Function Documentation

◆ add() [1/2]

virtual void add ( const T &  item)
pure virtual

Add an object to this Queue.

Parameters
itemvalue to be added to the Queue
Exceptions
Cancellation_Exceptionthrown if this Queue has been canceled.
Precondition
The Queue should not have been canceled prior to the invocation of this function.
Postcondition
If no exception is thrown, a copy of item will have been added to the Queue.

Implemented in BlockingQueue< T, LockType, StorageType >, BoundedQueue< T, LockType, StorageType >, LockedQueue< T, LockType, StorageType >, and MonitoredQueue< T, LockType, StorageType >.

◆ add() [2/2]

virtual bool add ( const T &  item,
unsigned long  timeout 
)
pure virtual

Add an object to this Queue.

Parameters
itemvalue to be added to the Queue
timeoutmaximum amount of time (milliseconds) this method may block the calling thread.
Returns
  • true if a copy of item can be added before timeout milliseconds elapse.
  • false otherwise.
Exceptions
Cancellation_Exceptionthrown if this Queue has been canceled.
Precondition
The Queue should not have been canceled prior to the invocation of this function.
Postcondition
If this function returns true a copy of item will have been added to the Queue.

Implemented in BlockingQueue< T, LockType, StorageType >, BoundedQueue< T, LockType, StorageType >, LockedQueue< T, LockType, StorageType >, and MonitoredQueue< T, LockType, StorageType >.

◆ cancel()

virtual void cancel ( )
pure virtual

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

Canceling a Queue more than once has no effect.

Postcondition
The next() methods will continue to return objects until the Queue has been emptied.
Once emptied, the next() methods will throw a Cancellation_Exception.
The add() methods will throw a Cancellation_Exceptions from this point on.

Implements Cancelable.

Implemented in BlockingQueue< T, LockType, StorageType >, BoundedQueue< T, LockType, StorageType >, LockedQueue< T, LockType, StorageType >, and MonitoredQueue< T, LockType, StorageType >.

◆ empty() [1/2]

virtual bool empty ( )
inlinevirtual

Test whether any values are available in this Queue.

Returns
  • true if there are no values available.
  • false if there are values available.

Reimplemented in BoundedQueue< T, LockType, StorageType >, and MonitoredQueue< T, LockType, StorageType >.

◆ empty() [2/2]

virtual bool empty ( unsigned long  timeout)
inlinevirtual

Test whether any values are available in this Queue.

Parameters
timeoutmaximum amount of time (milliseconds) this method may block the calling thread.
Returns
  • true if there are no values available.
  • false if there are values available.
Exceptions
Timeout_Exceptionthrown if timeout milliseconds expire before a value becomes available

Reimplemented in BoundedQueue< T, LockType, StorageType >, and MonitoredQueue< T, LockType, StorageType >.

◆ next() [1/2]

virtual T next ( )
pure virtual

Retrieve and remove a value from this Queue.

Returns
T next available value
Exceptions
Cancellation_Exceptionthrown if this Queue has been canceled.
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.

Implemented in BlockingQueue< T, LockType, StorageType >, BoundedQueue< T, LockType, StorageType >, LockedQueue< T, LockType, StorageType >, and MonitoredQueue< T, LockType, StorageType >.

◆ next() [2/2]

virtual T next ( unsigned long  timeout)
pure virtual

Retrieve and remove a value from this Queue.

Parameters
timeoutmaximum amount of time (milliseconds) this method may block the calling thread.
Returns
T next available value
Exceptions
Cancellation_Exceptionthrown if this Queue has been canceled.
Timeout_Exceptionthrown if the timeout expires before a value can be retrieved.
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.

Implemented in BlockingQueue< T, LockType, StorageType >, BoundedQueue< T, LockType, StorageType >, LockedQueue< T, LockType, StorageType >, and MonitoredQueue< T, LockType, StorageType >.

◆ size() [1/2]

virtual size_t size ( )
pure virtual

Count the values present in this Queue.

Returns
size_t number of elements available in the Queue.

Implemented in BlockingQueue< T, LockType, StorageType >, BoundedQueue< T, LockType, StorageType >, LockedQueue< T, LockType, StorageType >, and MonitoredQueue< T, LockType, StorageType >.

◆ size() [2/2]

virtual size_t size ( unsigned long  timeout)
pure virtual

Count the values present in this Queue.

Parameters
timeoutmaximum amount of time (milliseconds) this method may block the calling thread.
Returns
size_t number of elements available in the Queue.
Exceptions
Timeout_Exceptionthrown if timeout milliseconds expire before a value becomes available

Implemented in BlockingQueue< T, LockType, StorageType >, BoundedQueue< T, LockType, StorageType >, LockedQueue< T, LockType, StorageType >, and MonitoredQueue< T, LockType, StorageType >.


The documentation for this class was generated from the following file: