Nebula
|
#include <safequeue.h>
Thread-safe version of Util::Queue.
The SafeQueue is normally configured to signal an internal Event object when an element is enqueued, so that a worker-thread can wait for new elements to arrive. This is the default behaviour. This doesn't make sense for a continously running thread (i.e. a rendering thread), thus this behaviour can be disabled using the SetSignalOnEnqueueEnabled(). In this case, the Enqueue() method won't signal the internal event, and the Wait() method will return immediately without ever waiting.
Public Member Functions | |
SafeQueue () | |
constructor | |
SafeQueue (const SafeQueue< TYPE > &rhs) | |
copy constructor | |
void | operator= (const SafeQueue< TYPE > &rhs) |
assignment operator | |
void | SetSignalOnEnqueueEnabled (bool b) |
enable/disable signalling on Enqueue() (default is enabled) | |
bool | IsSignalOnEnqueueEnabled () const |
return signalling-on-Enqueue() flag | |
SizeT | Size () const |
returns number of elements in the queue | |
bool | IsEmpty () const |
return true if queue is empty | |
void | Clear () |
remove all elements from the queue | |
void | Enqueue (const TYPE &e) |
add element to the back of the queue | |
void | Enqueue (TYPE &&e) |
void | EnqueueArray (const Util::Array< TYPE > &a) |
enqueue an array of elements | |
TYPE | Dequeue () |
remove the element from the front of the queue | |
void | DequeueAll (Util::Array< TYPE > &outArray) |
dequeue all events (only requires one lock) | |
template<int STACK_SIZE> | |
void | DequeueAll (Util::Array< TYPE, STACK_SIZE > &outArray) |
Dequeue all events to an array with a stack size. | |
TYPE | Peek () const |
access to element at front of queue without removing it | |
void | Wait () |
wait until queue contains at least one element | |
void | WaitTimeout (int ms) |
wait until queue contains at least one element, or time-out happens | |
void | Signal () |
signal the internal event, so that Wait() will return | |
void | EraseMatchingElements (const TYPE &e) |
erase all matching elements | |
Protected Attributes | |
CriticalSection | criticalSection |
Event | enqueueEvent |
bool | signalOnEnqueueEnabled |
Util::Queue< TYPE > | queue |
Threading::SafeQueue< TYPE >::SafeQueue | ( | ) |
constructor
Threading::SafeQueue< TYPE >::SafeQueue | ( | const SafeQueue< TYPE > & | rhs | ) |
copy constructor
void Threading::SafeQueue< TYPE >::Clear | ( | ) |
remove all elements from the queue
TYPE Threading::SafeQueue< TYPE >::Dequeue | ( | ) |
remove the element from the front of the queue
void Threading::SafeQueue< TYPE >::DequeueAll | ( | Util::Array< TYPE > & | outArray | ) |
dequeue all events (only requires one lock)
void Threading::SafeQueue< TYPE >::DequeueAll | ( | Util::Array< TYPE, STACK_SIZE > & | outArray | ) |
Dequeue all events to an array with a stack size.
void Threading::SafeQueue< TYPE >::Enqueue | ( | const TYPE & | e | ) |
add element to the back of the queue
void Threading::SafeQueue< TYPE >::Enqueue | ( | TYPE && | e | ) |
void Threading::SafeQueue< TYPE >::EnqueueArray | ( | const Util::Array< TYPE > & | a | ) |
enqueue an array of elements
void Threading::SafeQueue< TYPE >::EraseMatchingElements | ( | const TYPE & | e | ) |
erase all matching elements
bool Threading::SafeQueue< TYPE >::IsEmpty | ( | ) | const |
return true if queue is empty
bool Threading::SafeQueue< TYPE >::IsSignalOnEnqueueEnabled | ( | ) | const |
return signalling-on-Enqueue() flag
void Threading::SafeQueue< TYPE >::operator= | ( | const SafeQueue< TYPE > & | rhs | ) |
assignment operator
TYPE Threading::SafeQueue< TYPE >::Peek | ( | ) | const |
access to element at front of queue without removing it
void Threading::SafeQueue< TYPE >::SetSignalOnEnqueueEnabled | ( | bool | b | ) |
enable/disable signalling on Enqueue() (default is enabled)
void Threading::SafeQueue< TYPE >::Signal | ( | ) |
SizeT Threading::SafeQueue< TYPE >::Size | ( | ) | const |
returns number of elements in the queue
void Threading::SafeQueue< TYPE >::Wait | ( | ) |
wait until queue contains at least one element
void Threading::SafeQueue< TYPE >::WaitTimeout | ( | int | ms | ) |
wait until queue contains at least one element, or time-out happens
|
protected |
|
protected |
|
protected |
|
protected |