NAP
Public Types | Public Member Functions | List of all members
TaskQueue Class Referencefinal

#include </opt/build/repo/nap/utility/src/utility/threading.h>

Public Types

using Task = std::function< void()>
 

Public Member Functions

 TaskQueue (int maxQueueItems=20)
 
bool enqueue (Task task)
 
void processBlocking ()
 
void process ()
 

Description

Thread safe queue for tasks that are encapsulated in function objects. It is possible to enqueue tasks at the end of the queue and to execute the tasks in the queue.

Member Typedef Documentation

◆ Task

using Task = std::function<void()>

Constructor & Destructor Documentation

◆ TaskQueue()

TaskQueue ( int  maxQueueItems = 20)

Constructor takes maximum number of items that can be in the queue at a time.

Member Function Documentation

◆ enqueue()

bool enqueue ( Task  task)

Add a task to the end of the queue.

◆ process()

void process ( )

Executes all tasks currently in the queue

◆ processBlocking()

void processBlocking ( )

If the queue is empty, this function blocks until tasks are enqueued and executes them. If the queue is not empty all the tasks are executed.