CuteLogger
Fast and simple logging solution for Qt based applications
|
The DataQueue provides a thread safe container for passing data between objects. More...
#include <dataqueue.h>
Public Types | |
enum | OverflowMode { OverflowModeDiscardOldest = 0 , OverflowModeDiscardNewest , OverflowModeWait } |
Overflow behavior modes. More... | |
Public Member Functions | |
DataQueue (int maxSize, OverflowMode mode) | |
virtual | ~DataQueue () |
Destructs a DataQueue. | |
void | push (const T &item) |
T | pop () |
int | count () const |
Returns the number of items in the queue. | |
The DataQueue provides a thread safe container for passing data between objects.
\threadsafe
DataQueue provides a limited size container for passing data between objects. One object can add data to the queue by calling push() while another object can remove items from the queue by calling pop().
DataQueue provides configurable behavior for handling overflows. It can discard the oldest, discard the newest or block the object calling push() until room has been freed in the queue by another object calling pop().
DataQueue is threadsafe and is therefore most appropriate when passing data between objects operating in different thread contexts.
enum DataQueue::OverflowMode |
|
explicit |
Constructs a DataQueue.
The size will be the maximum queue size and the mode will dictate overflow behavior.
T DataQueue< T >::pop | ( | ) |
void DataQueue< T >::push | ( | const T & | item | ) |
Pushes an item into the queue.
If the queue is full and overflow mode is OverflowModeWait then this function will block until pop() is called.