RigsofRods
Soft-body Physics Simulation
Public Member Functions | Private Member Functions | Private Attributes | Friends
RoR::Task Class Reference

/brief Handle for a task executed by ThreadPool More...

#include <ThreadPool.h>

Public Member Functions

void join () const
 Block the current thread and wait for the associated task to finish. More...
 

Private Member Functions

 Task (std::function< void()> task_func)
 
 Task (Task &)=delete
 
Taskoperator= (Task &)=delete
 

Private Attributes

bool m_is_finished = false
 Indicates whether the task execution has finished. More...
 
std::condition_variable m_finish_cv
 Used to signal the current thread when the task has finished. More...
 
std::mutex m_task_mutex
 Mutex which is locked while the task is running. More...
 
const std::function< void()> m_task_func
 Callable object which implements the task to execute. More...
 

Friends

class ThreadPool
 

Detailed Description

/brief Handle for a task executed by ThreadPool

Returned by ThreadPool instance when submitting a new task to run. Provides a thin wrapper around the callable object which implements the actual task. Allows for synchronization, i.e. to wait for the associated task to finish (see join()).

See also
ThreadPool

Definition at line 44 of file ThreadPool.h.

Constructor & Destructor Documentation

◆ Task() [1/2]

RoR::Task::Task ( std::function< void()>  task_func)
inlineprivate

Definition at line 71 of file ThreadPool.h.

◆ Task() [2/2]

RoR::Task::Task ( Task )
privatedelete

Member Function Documentation

◆ join()

void RoR::Task::join ( ) const
inline

Block the current thread and wait for the associated task to finish.

Definition at line 49 of file ThreadPool.h.

◆ operator=()

Task& RoR::Task::operator= ( Task )
privatedelete

Friends And Related Function Documentation

◆ ThreadPool

friend class ThreadPool
friend

Definition at line 46 of file ThreadPool.h.

Field Documentation

◆ m_finish_cv

std::condition_variable RoR::Task::m_finish_cv
mutableprivate

Used to signal the current thread when the task has finished.

Definition at line 76 of file ThreadPool.h.

◆ m_is_finished

bool RoR::Task::m_is_finished = false
private

Indicates whether the task execution has finished.

Definition at line 75 of file ThreadPool.h.

◆ m_task_func

const std::function<void()> RoR::Task::m_task_func
private

Callable object which implements the task to execute.

Definition at line 78 of file ThreadPool.h.

◆ m_task_mutex

std::mutex RoR::Task::m_task_mutex
mutableprivate

Mutex which is locked while the task is running.

Definition at line 77 of file ThreadPool.h.


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