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

MonitoredQueue Class Template Reference

#include <MonitoredQueue.h>

Inheritance diagram for MonitoredQueue:

Queue Lockable Cancelable NonCopyable List of all members.

Public Member Functions

 MonitoredQueue ()
 Create a new MonitoredQueue.
virtual ~MonitoredQueue ()
 Destroy a MonitoredQueue, delete remaining items.
virtual void add (const T &item)
virtual bool add (const 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)
virtual bool empty ()
virtual bool empty (unsigned long timeout)
virtual void acquire ()
virtual bool tryAcquire (unsigned long timeout)
virtual void release ()

Detailed Description

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

Author:
Eric Crahen <http://www.code-foo.com>
Date:
<2003-07-16T20:23:28-0400>
Version:
2.3.0
A MonitoredQueue is a Queue implementation that provides serialized access to the items added to it.

See also:
Queue


Member Function Documentation

virtual void acquire  )  [inline, virtual]
 

Acquire the Lockable 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.

Exceptions:
Interrupted_Exception thrown if the calling thread is interrupted before the operation completes.
Postcondition:
The Lockable is acquired only if no exception was thrown.

Implements Lockable.

virtual bool add const T &  item,
unsigned long  timeout
[inline, virtual]
 

Add a value to this Queue.

Parameters:
item value to be added to the Queue
timeout maximum 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_Exception thrown if this Queue has been canceled.
Interrupted_Exception thrown if the thread was interrupted while waiting to add a value
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.
See also:
Queue::add(const T& item, unsigned long timeout)

Implements Queue.

virtual void add const T &  item  )  [inline, virtual]
 

Add a value to this Queue.

Parameters:
item value to be added to the Queue
Exceptions:
Cancellation_Exception thrown if this Queue has been canceled.
Interrupted_Exception thrown if the thread was interrupted while waiting to add a value
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.
See also:
Queue::add(const T& item)

Implements Queue.

virtual void cancel  )  [inline, virtual]
 

Cancel this queue.

Postcondition:
Any threads blocked by a next() function will throw a Cancellation_Exception.
See also:
Queue::cancel()

Implements Queue.

virtual bool empty unsigned long  timeout  )  [inline, virtual]
 

Test whether any values are available in this Queue.

The calling thread is blocked until there are no values present in the Queue.

Parameters:
timeout maximum 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_Exception thrown if timeout milliseconds expire before a value becomes available
See also:
Queue::empty()

Reimplemented from Queue.

virtual bool empty  )  [inline, virtual]
 

Test whether any values are available in this Queue.

The calling thread is blocked until there are no values present in the Queue.

Returns:
  • true if there are no values available.
  • false if there are values available.
See also:
Queue::empty()

Reimplemented from Queue.

virtual bool isCanceled  )  [inline, virtual]
 

See also:
Queue::isCanceled()

Implements Cancelable.

virtual T next unsigned long  timeout  )  [inline, virtual]
 

Retrieve and remove a value from this Queue.

If invoked when there are no values present to return then the calling thread will be blocked until a value arrives in the Queue.

Parameters:
timeout maximum amount of time (milliseconds) this method may block the calling thread.
Returns:
T next available value
Exceptions:
Cancellation_Exception thrown if this Queue has been canceled.
Timeout_Exception thrown 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.

Implements Queue.

virtual T next  )  [inline, virtual]
 

Retrieve and remove a value from this Queue.

If invoked when there are no values present to return then the calling thread will be blocked until a value arrives in the Queue.

Returns:
T next available value
Exceptions:
Cancellation_Exception thrown if this Queue has been canceled.
Interrupted_Exception thrown if the thread was interrupted while waiting to retrieve a value
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.

Implements Queue.

virtual void release  )  [inline, virtual]
 

Release the Lockable 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.

Postcondition:
The Lockable is released only if no exception was thrown.

Implements Lockable.

virtual size_t size unsigned long  timeout  )  [inline, virtual]
 

See also:
Queue::size(unsigned long timeout)

Implements Queue.

virtual size_t size  )  [inline, virtual]
 

See also:
Queue::size()

Implements Queue.

virtual bool tryAcquire unsigned long  timeout  )  [inline, virtual]
 

Attempt to acquire the Lockable 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 (milliseconds) this method could block
Returns:
  • true if the operation completes and the Lockable is acquired before the timeout expires.
  • false if the operation times out before the Lockable can be acquired.
Exceptions:
Interrupted_Exception thrown if the calling thread is interrupted before the operation completes.
Postcondition:
The Lockable is acquired only if no exception was thrown.

Implements Lockable.


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