IQRF Gateway Daemon
|
Maintain queue of tasks and invoke sequential processing. More...
#include <TaskQueue.h>
Public Types | |
typedef std::function< void(T)> | ProcessTaskFunc |
Processing function type. More... | |
Public Member Functions | |
TaskQueue (ProcessTaskFunc processTaskFunc) | |
constructor More... | |
virtual | ~TaskQueue () |
destructor More... | |
int | pushToQueue (const T &task) |
Push task to queue. More... | |
void | stopQueue () |
Stop queue. More... | |
size_t | size () |
Get actual queue size. More... | |
Maintain queue of tasks and invoke sequential processing.
Provide asynchronous processing of incoming tasks of type T in dedicated worker thread. The tasks are processed in FIFO way. Processing function is passed as parameter in constructor.
typedef std::function<void(T)> TaskQueue< T >::ProcessTaskFunc |
Processing function type.
|
inline |
constructor
[in] | processTaskFunc | processing function |
Processing function is used in dedicated worker thread to process incoming queued tasks. The function must be thread safe. The worker thread is started.
destructor
Stops working thread
|
inline |
Push task to queue.
[in] | task | object to push to queue |
Pushes task to queue to be processed in worker thread. The task type T has to be copyable as the copy is pushed to queue container
|
inline |
Get actual queue size.
|
inline |
Stop queue.
Worker thread is explicitly stopped