ST_engine  0.3-ALPHA
Public Member Functions | List of all members
task_manager Class Reference

The Task Manager handles all things multi-threaded in the engine. More...

#include <task_manager.hpp>

Public Member Functions

 task_manager ()
 
 task_manager (uint8_t thread_num)
 
 ~task_manager ()
 
task_id start_task (ST::task *arg)
 
void start_task_lockfree (ST::task *arg)
 
void wait_for_task (task_id id)
 
void work_wait_for_task (task_id id)
 

Detailed Description

The Task Manager handles all things multi-threaded in the engine.

The task manager only needs to be initialized, it will start at least one worker thread

Definition at line 26 of file task_manager.hpp.

Constructor & Destructor Documentation

◆ task_manager() [1/2]

task_manager::task_manager ( )
explicit

Initializes the task manager. Starts as many worker threads as there are logical cores in the system - 1.

Definition at line 205 of file task_manager.cpp.

◆ task_manager() [2/2]

task_manager::task_manager ( uint8_t  thread_num)
explicit

Initializes the task manager. Starts worker threads equal to thread_num.

Parameters
msg_busA pointer to the global message bus.

Definition at line 240 of file task_manager.cpp.

◆ ~task_manager()

task_manager::~task_manager ( )

Closes the task manager. Waits for all threads to exit properly and finishes any unfinished tasks.

Definition at line 278 of file task_manager.cpp.

Member Function Documentation

◆ start_task()

task_id task_manager::start_task ( ST::task arg)

Start a new task on one of the task threads.

Parameters
argThe task object to use.
Returns
A task_id that can be used to wait for this task.

Definition at line 303 of file task_manager.cpp.

◆ start_task_lockfree()

void task_manager::start_task_lockfree ( ST::task arg)

Same as start_task except no task_id (lock) is created and the task has no dependencies.

Parameters
argThe task object to use.

Definition at line 316 of file task_manager.cpp.

◆ wait_for_task()

void task_manager::wait_for_task ( task_id  id)

Wait for a task to finish and do work from the work queue while waiting.

Parameters
idThe ID of the task.

Definition at line 341 of file task_manager.cpp.

◆ work_wait_for_task()

void task_manager::work_wait_for_task ( task_id  id)

Wait for a task to finish and do work from the work queue while waiting.

Parameters
idThe ID of the task.

Definition at line 325 of file task_manager.cpp.


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