API Documentation
Public Member Functions | List of all members
nkTasks::Thread Class Referencefinal

Symbolizes a thread. Base block to submit off-thread nkTasks::Task in this component. More...

Public Member Functions

 Thread () noexcept
 
 ~Thread ()
 
bool getCurrentlyWaiting () const
 
void addTask (nkMemory::UniquePtr< Task > task)
 
void run ()
 

Detailed Description

Symbolizes a thread. Base block to submit off-thread nkTasks::Task in this component.

Constructor & Destructor Documentation

◆ Thread()

nkTasks::Thread::Thread ( )
noexcept

Constructor.

◆ ~Thread()

nkTasks::Thread::~Thread ( )

Destructor.

Member Function Documentation

◆ getCurrentlyWaiting()

bool nkTasks::Thread::getCurrentlyWaiting ( ) const
Returns
Whether the thread is currently waiting for work (true) or not (false).

◆ addTask()

void nkTasks::Thread::addTask ( nkMemory::UniquePtr< Task task)

Submits a task to the thread.

Parameters
taskThe task to submit.
Remarks
The thread has no queuing mechanism. Only one task can be added while the thread is busy on another one, with no guarantee of when it will be picked up. In such case, adding another task on top will erase the queued one. To avoid this behaviour, it is needed to check whether the thread is waiting before adding a task. Else, a ThreadPool with a size of 1 thread will manage the queue automatically.

◆ run()

void nkTasks::Thread::run ( )

Starts the thread. Has to be called for the thread to create its context and run.


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