ONPOSIX
2.0
|
Implementation of a thread safe FIFO queue class. More...
#include <PosixSharedQueue.hpp>
Public Member Functions | |
PosixSharedQueue () | |
Constructor. Initialize the queue. | |
~PosixSharedQueue () | |
Destructor. Clean up the resources. | |
void | push (const T &data) |
Inserts an element in the queue. | |
T | pop () |
Extracts an element from the queue. | |
void | clear () |
Empties the queue. | |
size_t | size () const |
The current size of the queue. |
Private Member Functions | |
PosixSharedQueue (const PosixSharedQueue &) | |
PosixSharedQueue & | operator= (const PosixSharedQueue &) |
Private Attributes | |
std::queue< T > | queue_ |
pthread_cond_t | empty_ |
pthread_mutex_t | mutex_ |
Implementation of a thread safe FIFO queue class.
The template parameter is the type of the elements contained in the queue. The class is non copyable and makes use of POSIX threads (pthreads).
Definition at line 41 of file PosixSharedQueue.hpp.
|
private |
PosixSharedQueue | ( | ) |
Constructor. Initialize the queue.
runtime_error | if the initialization fails. |
Definition at line 69 of file PosixSharedQueue.hpp.
~PosixSharedQueue | ( | ) |
Destructor. Clean up the resources.
Definition at line 83 of file PosixSharedQueue.hpp.
void clear | ( | ) |
Empties the queue.
In order to efficiently accomplish its task, this function exchanges its content with an empty queue using the specialized version of swap() implemented for the STL container std::queue.
Definition at line 131 of file PosixSharedQueue.hpp.
|
private |
T pop | ( | ) |
Extracts an element from the queue.
Blocks the calling thread if the queue is empty.
Definition at line 111 of file PosixSharedQueue.hpp.
void push | ( | const T & | data | ) |
Inserts an element in the queue.
data | The element to be added in the queue. |
Definition at line 95 of file PosixSharedQueue.hpp.
size_t size | ( | ) | const |
The current size of the queue.
Definition at line 143 of file PosixSharedQueue.hpp.
|
private |
Definition at line 44 of file PosixSharedQueue.hpp.
|
mutableprivate |
Definition at line 45 of file PosixSharedQueue.hpp.
|
private |
Definition at line 43 of file PosixSharedQueue.hpp.