|
libosmscout 1.1.1
|
#include <libosmscout/include/osmscout/async/ProcessingQueue.h>
Public Member Functions | |
| ProcessingQueue () | |
| ProcessingQueue (size_t queueLimit) | |
| ProcessingQueue (const ProcessingQueue &)=delete | |
| ProcessingQueue & | operator= (const ProcessingQueue &)=delete |
| virtual | ~ProcessingQueue ()=default |
| void | PushTask (const T &task) |
| void | PushTask (T &&task) |
| std::optional< T > | PopTask () |
| void | Stop () |
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 |
|
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 |
| 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 |