#include <dataqueue.h>
It uses similar member names as std::queue<>, for consistency.
Definition at line 40 of file dataqueue.h.
Public Member Functions | |
void | push (Data *data) |
Pushes data into the end of the queue. | |
Data * | pop () |
Pops the next element off the front of the queue. | |
Data * | wait_pop (int timeout=-1) |
Pops the next element off the front of the queue, and waits until one exists if empty. | |
void | append_from (DataQueue &other) |
Pops all data from other and appends it to this. | |
bool | empty () const |
Returns true if the queue is empty. | |
size_t | size () const |
Returns number of items in the queue. |
void Barry::DataQueue::push | ( | Data * | data | ) |
Pushes data into the end of the queue.
The queue owns this pointer as soon as the function is called. In the case of an exception, it will be freed. Performs a thread broadcast once new data has been added.
Definition at line 59 of file dataqueue.cc.
Data * Barry::DataQueue::pop | ( | ) |
Pops the next element off the front of the queue.
Returns 0 if empty. The queue no longer owns this pointer upon return.
Definition at line 86 of file dataqueue.cc.
Data * Barry::DataQueue::wait_pop | ( | int | timeout = -1 |
) |
Pops the next element off the front of the queue, and waits until one exists if empty.
If still no data on timeout, returns null. (unlock the access mutex while waiting!)
Timeout specified in milliseconds. Default is wait forever.
Definition at line 108 of file dataqueue.cc.
References size(), and Barry::ThreadTimeout().
void Barry::DataQueue::append_from | ( | DataQueue & | other | ) |
Pops all data from other and appends it to this.
After calling this function, other will be empty, and this will contain all its data.
In the case of an exception, any uncopied data will remain in other.
This is a locking optimization, so all copying can happen inside one lock, instead of locking for each copy.
Definition at line 176 of file dataqueue.cc.
References m_accessMutex, and m_queue.
bool Barry::DataQueue::empty | ( | ) | const |
size_t Barry::DataQueue::size | ( | ) | const |
Returns number of items in the queue.
Definition at line 206 of file dataqueue.cc.
Referenced by wait_pop().