Instrument Neutral Distributed Interface INDI
2.0.2
|
The UniqueQueue class is a thread-safe FIFO container adapter. More...
#include <uniquequeue.h>
Public Member Functions | |
void | push (T &&data) |
Move data to queue. More... | |
bool | pop (T &dest) |
Pop data from queue. More... | |
bool | pop (T &dest, uint32_t msecs) |
Pop data from queue. More... | |
void | waitForEmpty () const |
Wait for an empty queue. More... | |
bool | waitForEmpty (uint32_t msecs) const |
Wait for an empty queue. More... | |
void | clear () |
Clear queue. More... | |
void | abort () |
Clear queue and exit pop methods with false return. More... | |
size_t | size () const |
Return the number of items in the queue. More... | |
Protected Attributes | |
std::queue< T > | queue |
std::mutex | mutex |
std::condition_variable | decrease |
std::condition_variable | increase |
The UniqueQueue class is a thread-safe FIFO container adapter.
Data is move to the queue, which ensures high efficiency when collecting data, e.g. for processing. This class ensures that threads are wake up waiting for data. It also provides a convenient "abort" method to wake up those waiting if there is no more data to process. Don't use it for large class/arrays (sizeof T). Provide an interface that allows data to be swapped/moved as pointers, like std::vector or simple pointers.
Definition at line 35 of file uniquequeue.h.
|
inline |
Clear queue and exit pop methods with false return.
Definition at line 174 of file uniquequeue.h.
|
inline |
Clear queue.
Definition at line 145 of file uniquequeue.h.
|
inline |
Pop data from queue.
dest | the data will be swapped and destroyed |
Definition at line 105 of file uniquequeue.h.
|
inline |
Pop data from queue.
dest | the data will be swapped and destroyed |
msecs | timeout in milliseconds |
Definition at line 121 of file uniquequeue.h.
|
inline |
Move data to queue.
data | the data will be moved using std::move |
Definition at line 97 of file uniquequeue.h.
|
inline |
Return the number of items in the queue.
Definition at line 138 of file uniquequeue.h.
|
inline |
Wait for an empty queue.
Definition at line 154 of file uniquequeue.h.
|
inline |
Wait for an empty queue.
msecs | timeout in milliseconds |
Definition at line 164 of file uniquequeue.h.
|
mutableprotected |
Definition at line 91 of file uniquequeue.h.
|
mutableprotected |
Definition at line 92 of file uniquequeue.h.
|
mutableprotected |
Definition at line 89 of file uniquequeue.h.
|
protected |
Definition at line 88 of file uniquequeue.h.