libosmscout
0.1
|
A ProcessingQueue is a special multi-threaded safe implementation of a queue. More...
#include <ProcessingQueue.h>
Public Member Functions | |
bool | Finished () |
Return true, if the queue is stopped and empty, else false. More... | |
ProcessingQueue & | operator= (const ProcessingQueue &)=delete |
std::optional< T > | PopTask () |
Move one data entry out of the queue (FIFO semantics). More... | |
ProcessingQueue () | |
Initialize a unbounded queue. More... | |
ProcessingQueue (const ProcessingQueue &)=delete | |
ProcessingQueue (size_t queueLimit) | |
Initialize a bounded queue. More... | |
void | PushTask (const T &task) |
Push a copy of the given data into the queue. More... | |
void | PushTask (T &&task) |
Push a copy or move the given data into the queue. More... | |
void | Stop () |
Signal that all data has been pushed into the queue. More... | |
virtual | ~ProcessingQueue ()=default |
A ProcessingQueue is a special multi-threaded safe implementation of a queue.
The goal is to use this queues as a asynchronous pipeline between individual agents or worker threads.
The queue has FIFO semantics.
A queue can have multiple producers and consumers. There is currently no Peek() method data that has been taken has either to be consumed, pushed back or dropped.
The queue data should be movable but can be copyable also. If the content is not movable additional CPU overhead for copying data is to be expected.
Note that even is the content is moveable is should be assumed that moving data through the queue has it own cost.
T | Type of the queue content |
|
default |
Initialize a unbounded queue.
T |
|
explicit |
Initialize a bounded queue.
The queue is guaranteed to hold no more than the given amount of data entries. Producer will be blocked until the queue shrinks below its limit before data can be pushed.
T |
queueLimit | Queue size limit |
|
delete |
|
virtualdefault |
bool osmscout::ProcessingQueue< R >::Finished |
Return true, if the queue is stopped and empty, else false.
R |
Referenced by osmscout::AsyncWorker::Loop().
|
delete |
std::optional< T > osmscout::ProcessingQueue< T >::PopTask |
Move one data entry out of the queue (FIFO semantics).
No data will be returned if the queue is stopped and empty.
T |
Referenced by osmscout::AsyncWorker::Loop().
void osmscout::ProcessingQueue< T >::PushTask | ( | const T & | task | ) |
Push a copy of the given data into the queue.
Pushing data will be blocked until queue size is below limit.
T |
task |
void osmscout::ProcessingQueue< T >::PushTask | ( | T && | task | ) |
Push a copy or move the given data into the queue.
Pushing data will be blocked until queue size is below limit.
T |
task |
void osmscout::ProcessingQueue< R >::Stop |
Signal that all data has been pushed into the queue.
R |
Referenced by osmscout::AsyncWorker::DeleteLater(), and osmscout::AsyncWorker::~AsyncWorker().