Helios Engine 0.1.0
A modular ECS based data-oriented C++23 game engine
 
Loading...
Searching...
No Matches
helios::async::AsyncTask Class Reference

Handle to an asynchronous task managed by the Executor. More...

#include <async_task.hpp>

Public Member Functions

 AsyncTask ()=default
 
 AsyncTask (const AsyncTask &)=default
 
 AsyncTask (AsyncTask &&) noexcept=default
 
 ~AsyncTask ()=default
 
AsyncTaskoperator= (const AsyncTask &)=default
 
AsyncTaskoperator= (AsyncTask &&) noexcept=default
 
void Reset ()
 Resets the underlying asynchronous task handle.
 
bool operator== (const AsyncTask &other) const noexcept
 
bool operator!= (const AsyncTask &other) const noexcept
 
bool Done () const
 Checks if the asynchronous task has completed.
 
bool Empty () const
 Checks if the task handle is empty (not associated with any task).
 
size_t Hash () const
 Returns a hash value for the task.
 
size_t UseCount () const
 Returns the number of references to the underlying task.
 

Static Public Member Functions

static constexpr TaskType GetTaskType () noexcept
 Gets the type of the task.
 

Friends

class Executor
 
class SubTaskGraph
 

Detailed Description

Handle to an asynchronous task managed by the Executor.

Wraps a tf::AsyncTask, providing methods to query task state and manage its lifecycle. Instances are typically returned by Executor's asynchronous methods.

Note
Thread-safe.

Definition at line 20 of file async_task.hpp.

Constructor & Destructor Documentation

◆ AsyncTask() [1/3]

helios::async::AsyncTask::AsyncTask ( )
default

◆ AsyncTask() [2/3]

helios::async::AsyncTask::AsyncTask ( const AsyncTask )
default

◆ AsyncTask() [3/3]

helios::async::AsyncTask::AsyncTask ( AsyncTask &&  )
defaultnoexcept

◆ ~AsyncTask()

helios::async::AsyncTask::~AsyncTask ( )
default

Member Function Documentation

◆ Done()

bool helios::async::AsyncTask::Done ( ) const
inline

Checks if the asynchronous task has completed.

Returns
True if the task is done, false otherwise.

Returns false if task is empty.

Definition at line 83 of file async_task.hpp.

83 {
84 if (Empty()) [[unlikely]] {
85 return false;
86 }
87
88 return task_.is_done();
89}
bool Empty() const
Checks if the task handle is empty (not associated with any task).

◆ Empty()

bool helios::async::AsyncTask::Empty ( ) const
inline

Checks if the task handle is empty (not associated with any task).

Returns
True if empty, false otherwise.

Definition at line 49 of file async_task.hpp.

49{ return task_.empty(); }

◆ GetTaskType()

static constexpr TaskType helios::async::AsyncTask::GetTaskType ( )
inlinestaticconstexprnoexcept

Gets the type of the task.

Returns
TaskType::Async

Definition at line 69 of file async_task.hpp.

69{ return TaskType::Async; }
@ Async
Asynchronous task executed independently.

◆ Hash()

size_t helios::async::AsyncTask::Hash ( ) const
inline

Returns a hash value for the task.

Returns
Hash value.

Returns '0' if task is empty.

Definition at line 91 of file async_task.hpp.

91 {
92 if (Empty()) [[unlikely]] {
93 return 0;
94 }
95
96 return task_.hash_value();
97}

◆ operator!=()

bool helios::async::AsyncTask::operator!= ( const AsyncTask other) const
inlinenoexcept

Definition at line 36 of file async_task.hpp.

36{ return !(*this == other); }

◆ operator=() [1/2]

AsyncTask & helios::async::AsyncTask::operator= ( AsyncTask &&  )
defaultnoexcept

◆ operator=() [2/2]

AsyncTask & helios::async::AsyncTask::operator= ( const AsyncTask )
default

◆ operator==()

bool helios::async::AsyncTask::operator== ( const AsyncTask other) const
inlinenoexcept

Definition at line 35 of file async_task.hpp.

35{ return task_.hash_value() == other.task_.hash_value(); }

◆ Reset()

void helios::async::AsyncTask::Reset ( )
inline

Resets the underlying asynchronous task handle.

Definition at line 33 of file async_task.hpp.

33{ task_.reset(); }

◆ UseCount()

size_t helios::async::AsyncTask::UseCount ( ) const
inline

Returns the number of references to the underlying task.

Returns
Reference count.

Returns '0' if task is empty.

Definition at line 63 of file async_task.hpp.

63{ return task_.use_count(); }

Friends And Related Symbol Documentation

◆ Executor

friend class Executor
friend

Definition at line 79 of file async_task.hpp.

◆ SubTaskGraph

friend class SubTaskGraph
friend

Definition at line 80 of file async_task.hpp.