IQRF Gateway Daemon
Public Types | Public Member Functions | List of all members
TaskQueue< T > Class Template Reference

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

Detailed Description

template<class T>
class TaskQueue< T >

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.

Member Typedef Documentation

◆ ProcessTaskFunc

template<class T>
typedef std::function<void(T)> TaskQueue< T >::ProcessTaskFunc

Processing function type.

Constructor & Destructor Documentation

◆ TaskQueue()

template<class T>
TaskQueue< T >::TaskQueue ( ProcessTaskFunc  processTaskFunc)
inline

constructor

Parameters
[in]processTaskFuncprocessing 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.

◆ ~TaskQueue()

template<class T>
virtual TaskQueue< T >::~TaskQueue ( )
inlinevirtual

destructor

Stops working thread

Member Function Documentation

◆ pushToQueue()

template<class T>
int TaskQueue< T >::pushToQueue ( const T &  task)
inline

Push task to queue.

Parameters
[in]taskobject to push to queue
Returns
size of 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

◆ size()

template<class T>
size_t TaskQueue< T >::size ( )
inline

Get actual queue size.

Returns
queue size

◆ stopQueue()

template<class T>
void TaskQueue< T >::stopQueue ( )
inline

Stop queue.

Worker thread is explicitly stopped


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