libosmscout 1.1.1
Loading...
Searching...
No Matches
osmscout::ProcessingQueue< T > Class Template Reference

#include <libosmscout/include/osmscout/async/ProcessingQueue.h>

Public Member Functions

 ProcessingQueue ()
 ProcessingQueue (size_t queueLimit)
 ProcessingQueue (const ProcessingQueue &)=delete
ProcessingQueueoperator= (const ProcessingQueue &)=delete
virtual ~ProcessingQueue ()=default
void PushTask (const T &task)
void PushTask (T &&task)
std::optional< T > PopTask ()
void Stop ()

Detailed Description

template<typename T>
class osmscout::ProcessingQueue< T >

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.

Template Parameters
TType of the queue content

Constructor & Destructor Documentation

◆ ProcessingQueue() [1/3]

template<class T>
osmscout::ProcessingQueue< T >::ProcessingQueue ( )
default

Initialize a unbounded queue.

Template Parameters
T

◆ ProcessingQueue() [2/3]

template<class T>
osmscout::ProcessingQueue< T >::ProcessingQueue ( size_t queueLimit)
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.

Template Parameters
T
Parameters
queueLimitQueue size limit

◆ ProcessingQueue() [3/3]

template<typename T>
osmscout::ProcessingQueue< T >::ProcessingQueue ( const ProcessingQueue< T > & )
delete

◆ ~ProcessingQueue()

template<typename T>
virtual osmscout::ProcessingQueue< T >::~ProcessingQueue ( )
virtualdefault

Member Function Documentation

◆ operator=()

template<typename T>
ProcessingQueue & osmscout::ProcessingQueue< T >::operator= ( const ProcessingQueue< T > & )
delete

◆ PopTask()

template<class T>
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.

Template Parameters
T
Returns

◆ PushTask() [1/2]

template<class 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.

Template Parameters
T
Parameters
task

◆ PushTask() [2/2]

template<class T>
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.

Template Parameters
T
Parameters
task

◆ Stop()

template<class R>
void osmscout::ProcessingQueue< R >::Stop ( )

Signal that all data has been pushed into the queue.

Template Parameters
R

The documentation for this class was generated from the following file: