co_ecs 0.9.0
Cobalt ECS
Loading...
Searching...
No Matches
co_ecs::task_t Class Reference

Represents a task that can be executed, monitored for completion, and linked to a parent task. More...

#include <task.hpp>

Public Member Functions

 task_t ()=default
 Constructs an empty task.
 
 task_t (auto &&func, task_t *parent=nullptr)
 Constructs a task from a callable function and optionally links it to a parent task.
 
void execute ()
 Executes the task's function and marks it as completed.
 
bool is_completed () const noexcept
 Checks if the task has been completed.
 
task_tparent () const noexcept
 Retrieves the parent task if it exists.
 

Detailed Description

Represents a task that can be executed, monitored for completion, and linked to a parent task.

Constructor & Destructor Documentation

◆ task_t() [1/2]

co_ecs::task_t::task_t ( )
default

Constructs an empty task.

◆ task_t() [2/2]

co_ecs::task_t::task_t ( auto && func,
task_t * parent = nullptr )
inline

Constructs a task from a callable function and optionally links it to a parent task.

Parameters
funcA callable object to be executed as the task.
parentOptional pointer to a parent task, defaults to nullptr if no parent is specified.

Member Function Documentation

◆ execute()

void co_ecs::task_t::execute ( )
inline

Executes the task's function and marks it as completed.

◆ is_completed()

bool co_ecs::task_t::is_completed ( ) const
inlinenoexcept

Checks if the task has been completed.

Returns
True if the task is completed, otherwise false.

◆ parent()

task_t * co_ecs::task_t::parent ( ) const
inlinenoexcept

Retrieves the parent task if it exists.

Returns
Pointer to the parent task, or nullptr if there is no parent.

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