Equalizer  1.2.1
Public Member Functions
co::base::MTQueue< T, S > Class Template Reference

A thread-safe queue with a blocking read access. More...

#include <mtQueue.h>

List of all members.

Public Member Functions

 MTQueue ()
 Construct a new queue.
 MTQueue (const MTQueue< T, S > &from)
 Construct a copy of a queue.
 ~MTQueue ()
 Destruct this Queue.
MTQueue< T, S > & operator= (const MTQueue< T, S > &from)
 Assign the values of another queue.
bool isEmpty () const
size_t getSize () const
size_t waitSize (const size_t minSize) const
 Wait for the size to be at least the number of given elements.
void clear ()
 Reset (empty) the queue.
pop ()
 Retrieve and pop the front element from the queue, may block.
bool timedPop (const unsigned timeout, T &element)
 Retrieve and pop the front element from the queue.
bool tryPop (T &result)
 Retrieve and pop the front element from the queue if it is not empty.
void tryPop (const size_t num, std::vector< T > &result)
 Try to retrieve a number of items for the front of the queue.
bool getFront (T &result) const
bool getBack (T &result) const
void push (const T &element)
 Push a new element to the back of the queue.
void push (const std::vector< T > &elements)
 Push a vector of elements to the back of the queue.
void pushFront (const T &element)
 Push a new element to the front of the queue.
void pushFront (const std::vector< T > &elements)
 Push a vector of elements to the front of the queue.

Detailed Description

template<typename T, size_t S = ULONG_MAX>
class co::base::MTQueue< T, S >

A thread-safe queue with a blocking read access.

Typically used to communicate between two execution threads.

S defines the maximum capacity of the Queue<T>. When the capacity is reached, pushing new values blocks until items have been consumed.

Definition at line 41 of file mtQueue.h.


Constructor & Destructor Documentation

template<typename T, size_t S = ULONG_MAX>
co::base::MTQueue< T, S >::MTQueue ( ) [inline]

Construct a new queue.

Version:
1.0

Definition at line 47 of file mtQueue.h.

template<typename T, size_t S = ULONG_MAX>
co::base::MTQueue< T, S >::MTQueue ( const MTQueue< T, S > &  from) [inline]

Construct a copy of a queue.

Version:
1.0

Definition at line 50 of file mtQueue.h.

template<typename T, size_t S = ULONG_MAX>
co::base::MTQueue< T, S >::~MTQueue ( ) [inline]

Destruct this Queue.

Version:
1.0

Definition at line 53 of file mtQueue.h.


Member Function Documentation

template<typename T, size_t S = ULONG_MAX>
void co::base::MTQueue< T, S >::clear ( ) [inline]

Reset (empty) the queue.

Version:
1.0

Definition at line 89 of file mtQueue.h.

template<typename T, size_t S = ULONG_MAX>
bool co::base::MTQueue< T, S >::getBack ( T &  result) const [inline]
Parameters:
resultthe last value or unmodified.
Returns:
true if an element was placed in result, false if the queue is empty.
Version:
1.0

Definition at line 221 of file mtQueue.h.

template<typename T, size_t S = ULONG_MAX>
bool co::base::MTQueue< T, S >::getFront ( T &  result) const [inline]
Parameters:
resultthe front value or unmodified.
Returns:
true if an element was placed in result, false if the queue is empty.
Version:
1.0

Definition at line 201 of file mtQueue.h.

template<typename T, size_t S = ULONG_MAX>
size_t co::base::MTQueue< T, S >::getSize ( ) const [inline]
Returns:
the number of items currently in the queue.
Version:
1.0

Definition at line 69 of file mtQueue.h.

Referenced by co::CommandQueue::getSize().

+ Here is the caller graph for this function:

template<typename T, size_t S = ULONG_MAX>
bool co::base::MTQueue< T, S >::isEmpty ( ) const [inline]
Returns:
true if the queue is empty, false otherwise.
Version:
1.0

Definition at line 66 of file mtQueue.h.

Referenced by co::CommandQueue::isEmpty().

+ Here is the caller graph for this function:

template<typename T, size_t S = ULONG_MAX>
MTQueue< T, S >& co::base::MTQueue< T, S >::operator= ( const MTQueue< T, S > &  from) [inline]

Assign the values of another queue.

Version:
1.0

Definition at line 56 of file mtQueue.h.

template<typename T, size_t S = ULONG_MAX>
T co::base::MTQueue< T, S >::pop ( ) [inline]

Retrieve and pop the front element from the queue, may block.

Version:
1.0

Definition at line 100 of file mtQueue.h.

template<typename T, size_t S = ULONG_MAX>
void co::base::MTQueue< T, S >::push ( const T &  element) [inline]

Push a new element to the back of the queue.

Version:
1.0

Definition at line 236 of file mtQueue.h.

Referenced by co::CommandQueue::wakeup().

+ Here is the caller graph for this function:

template<typename T, size_t S = ULONG_MAX>
void co::base::MTQueue< T, S >::push ( const std::vector< T > &  elements) [inline]

Push a vector of elements to the back of the queue.

Version:
1.0

Definition at line 247 of file mtQueue.h.

template<typename T, size_t S = ULONG_MAX>
void co::base::MTQueue< T, S >::pushFront ( const T &  element) [inline]

Push a new element to the front of the queue.

Version:
1.0

Definition at line 259 of file mtQueue.h.

template<typename T, size_t S = ULONG_MAX>
void co::base::MTQueue< T, S >::pushFront ( const std::vector< T > &  elements) [inline]

Push a vector of elements to the front of the queue.

Version:
1.0

Definition at line 270 of file mtQueue.h.

template<typename T, size_t S = ULONG_MAX>
bool co::base::MTQueue< T, S >::timedPop ( const unsigned  timeout,
T &  element 
) [inline]

Retrieve and pop the front element from the queue.

Parameters:
timeoutthe timeout
elementthe element returned
Returns:
true if an element was popped
Exceptions:
Exceptionon timeout.
Version:
1.1

Definition at line 123 of file mtQueue.h.

template<typename T, size_t S = ULONG_MAX>
bool co::base::MTQueue< T, S >::tryPop ( T &  result) [inline]

Retrieve and pop the front element from the queue if it is not empty.

Parameters:
resultthe front value or unmodified.
Returns:
true if an element was placed in result, false if the queue is empty.
Version:
1.0

Definition at line 150 of file mtQueue.h.

template<typename T, size_t S = ULONG_MAX>
void co::base::MTQueue< T, S >::tryPop ( const size_t  num,
std::vector< T > &  result 
) [inline]

Try to retrieve a number of items for the front of the queue.

Between zero and the given number of items are appended to the vector.

Parameters:
numthe maximum number of items to retrieve
resultthe front value or unmodified.
Returns:
true if an element was placed in result, false if the queue is empty.
Version:
1.1.6

Definition at line 178 of file mtQueue.h.

template<typename T, size_t S = ULONG_MAX>
size_t co::base::MTQueue< T, S >::waitSize ( const size_t  minSize) const [inline]

Wait for the size to be at least the number of given elements.

Returns:
the current size when the condition was fulfilled.
Version:
1.0

Definition at line 77 of file mtQueue.h.


The documentation for this class was generated from the following file:
Generated on Fri Jun 8 2012 15:44:34 for Equalizer 1.2.1 by  doxygen 1.8.0