The Micro C++ Library
|
A PCQueue implements a threadsafe blocking Producer/Consumer Queue supporting a maximum size. More...
#include <micxx.hxx>
Inherits micxx::Condition.
Public Member Functions | |
PCQueue (unsigned maxSize=16384) | |
Create a new and empty PCQueue with the specified maxSize. | |
virtual | ~PCQueue () |
virtual void | clear () |
Remove all elements from the queue and interrupt all currently blocking enqueue(T) or dequeue() calls. | |
virtual unsigned | getMaxSize () const |
The maximum size of elements, that may be stored within this PCQueue. | |
virtual T & | head () |
A reference to the next element from this PCQueue, that would be returned by the next subsequent call of dequeue(). | |
virtual T | dequeue () |
Remove and return the next element from this PCQueue. | |
virtual bool | enqueue (T t) |
Add a copy of data element t to this PCQueue. | |
virtual std::size_t | size () |
The currently available elements within this PCQueue. | |
Protected Attributes | |
unsigned | maxSize |
std::list< T > | queue |
The internal queue. |
A PCQueue implements a threadsafe blocking Producer/Consumer Queue supporting a maximum size.
A PCQueue is typically used when there are one or more producer threads that continuously enqueue data elements into a queue and one or more consumer threads concurrently read continuously data elements from this queue.
micxx::PCQueue< T >::PCQueue | ( | unsigned | maxSize = 16384 | ) |
Create a new and empty PCQueue with the specified maxSize.
maxSize | The maximum size of this PCQueue. All enqueue(T) calls after reaching this size will block the current thread until a subsequent dequeue() removes one element from the queue. |
micxx::PCQueue< T >::~PCQueue | ( | ) | [virtual] |
{ }
void micxx::PCQueue< T >::clear | ( | ) | [virtual] |
Remove all elements from the queue and interrupt all currently blocking enqueue(T) or dequeue() calls.
T micxx::PCQueue< T >::dequeue | ( | ) | [virtual] |
Remove and return the next element from this PCQueue.
If there is cuurently no such element available, the calling thread is blocked until an new element is added by enqueue(T).
bool micxx::PCQueue< T >::enqueue | ( | T | t | ) | [virtual] |
Add a copy of data element t to this PCQueue.
If the current size is greater or equal to this PCQueue's maximum size. All enqueue(T) calls after reaching this size will block the current thread until a subsequent dequeue() removes one element from the queue
unsigned micxx::PCQueue< T >::getMaxSize | ( | ) | const [inline, virtual] |
T & micxx::PCQueue< T >::head | ( | ) | [virtual] |
std::size_t micxx::PCQueue< T >::size | ( | ) | [virtual] |
unsigned micxx::PCQueue< T >::maxSize [protected] |
std::list<T> micxx::PCQueue< T >::queue [protected] |
The internal queue.