Squid::Tasks 1.0.0
C++14 coroutine-based task library for games
TaskManager Class Reference

Manager that runs and resumes a collection of tasks. More...

#include <TaskManager.h>

Public Member Functions

template<typename tRet >
TaskHandle< tRet > Run (Task< tRet > &&in_task)
 Destructor (disables copy/move construction + assignment) More...
 
template<typename tRet >
WeakTaskHandle RunManaged (Task< tRet > &&in_task)
 Run a managed task. More...
 
void RunWeakTask (WeakTask &&in_task)
 Run a weak task. More...
 
void KillAllTasks ()
 Call Task::Kill() on all tasks (managed + unmanaged)
 
Task StopAllTasks ()
 Issue a stop request using Task::RequestStop() on all active tasks (managed and unmanaged) More...
 
void Update ()
 Call Task::Resume() on all active tasks exactly once (managed + unmanaged)
 
std::string GetDebugString (std::optional< TaskDebugStackFormatter > in_formatter={}) const
 Get a debug string containing a list of all active tasks.
 

Detailed Description

Manager that runs and resumes a collection of tasks.

Member Function Documentation

◆ Run()

template<typename tRet >
TaskHandle< tRet > TaskManager::Run ( Task< tRet > &&  in_task)
inline

Destructor (disables copy/move construction + assignment)

Run an unmanaged task

Run() return a TaskHandle<> that holds a strong reference to the task. If there are ever no strong references remaining to an unmanaged task, it will immediately be killed and removed from the manager.

◆ RunManaged()

template<typename tRet >
WeakTaskHandle TaskManager::RunManaged ( Task< tRet > &&  in_task)
inline

Run a managed task.

RunManaged() return a WeakTaskHandle, meaning it can be used to run a "fire-and-forget" background task in situations where it is not necessary to observe or control task lifetime.

◆ RunWeakTask()

void TaskManager::RunWeakTask ( WeakTask &&  in_task)
inline

Run a weak task.

RunWeakTask() runs a WeakTask. The caller is assumed to have already created a strong TaskHandle<> that references the WeakTask, thus keeping it from being killed. When the last strong reference to the WeakTask is destroyed, the task will immediately be killed and removed from the manager.

◆ StopAllTasks()

Task TaskManager::StopAllTasks ( )
inline

Issue a stop request using Task::RequestStop() on all active tasks (managed and unmanaged)

Returns a new awaiter task that will wait until all those tasks have all terminated.


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