NAP
Public Member Functions | List of all members
WorkerThread Class Reference

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

Public Member Functions

 WorkerThread ()
 
 WorkerThread (bool blocking, int maxQueueItems=20)
 
virtual ~WorkerThread ()
 
void enqueue (TaskQueue::Task task)
 
void start ()
 
void stop ()
 
bool isRunning ()
 
virtual void loop ()
 

Description

A single thread that runs its own task queue

Constructor & Destructor Documentation

◆ WorkerThread() [1/2]

Explicit default constructor

◆ WorkerThread() [2/2]

WorkerThread ( bool  blocking,
int  maxQueueItems = 20 
)
Parameters
blockingwhen true: the threads blocks and waits for enqueued tasks to perform, false: the threads runs through the loop as fast as possible and emits 'execute' every iteration
maxQueueItemsthe maximum number of items in the task queue

◆ ~WorkerThread()

virtual ~WorkerThread ( )
virtual

Member Function Documentation

◆ enqueue()

void enqueue ( TaskQueue::Task  task)

enqueues a task to be performed on this thread

◆ isRunning()

bool isRunning ( )

Returns wether the thread is running and not shutting down.

◆ loop()

virtual void loop ( )
virtual

Overwrite this method to specify behaviour to be executed each loop after processing the task queue.

◆ start()

void start ( )

Start the thread and the thread loop.

◆ stop()

void stop ( )

Stop the thread loop and join the thread.