Helios Engine
A modular ECS based data-oriented C++23 game engine framework
Loading...
Searching...
No Matches
helios::async::Future< T > Class Template Reference

Wrapper around tf::Future for handling asynchronous task results. More...

#include <future.hpp>

Public Member Functions

 Future ()=default
 Future (const Future &)=delete
 Future (Future &&other) noexcept=default
 ~Future ()=default
Futureoperator= (const Future &)=delete
Futureoperator= (Future &&other) noexcept=default
Get ()
 Blocks until the result is available and returns it.
bool Cancel ()
 Attempts to cancel the associated task.
void Wait ()
 Blocks until the result is available.
template<typename Rep, typename Period>
requires requires { typename std::chrono::duration<Rep, Period>; }
std::future_status WaitFor (const std::chrono::duration< Rep, Period > &rel_time) const
 Waits for the result to become available for the specified duration.
template<typename Clock, typename Duration>
requires requires { typename std::chrono::time_point<Clock, Duration>; }
std::future_status WaitUntil (const std::chrono::time_point< Clock, Duration > &abs_time) const
 Waits for the result to become available until the specified time point.
bool Valid () const
 Checks if the future has a shared state.

Friends

class Executor
class SubTaskGraph

Detailed Description

template<typename T>
class helios::async::Future< T >

Wrapper around tf::Future for handling asynchronous task results.

Provides methods to wait for and retrieve results from asynchronous operations. Move-only type that represents the eventual result of an async computation.

Note
All member functions are thread-safe.
Template Parameters
TThe type of value the future will hold

Definition at line 22 of file future.hpp.

Constructor & Destructor Documentation

◆ Future() [1/3]

template<typename T>
helios::async::Future< T >::Future ( )
default

◆ Future() [2/3]

template<typename T>
helios::async::Future< T >::Future ( const Future< T > & )
delete

◆ Future() [3/3]

template<typename T>
helios::async::Future< T >::Future ( Future< T > && other)
defaultnoexcept

◆ ~Future()

template<typename T>
helios::async::Future< T >::~Future ( )
default

Member Function Documentation

◆ Cancel()

template<typename T>
bool helios::async::Future< T >::Cancel ( )
inline

Attempts to cancel the associated task.

May not succeed if the task has already started or completed.

Returns
True if cancellation was successful, false otherwise

Definition at line 105 of file future.hpp.

◆ Get()

template<typename T>
T helios::async::Future< T >::Get ( )
inline

Blocks until the result is available and returns it.

This method blocks the calling thread. Can only be called once.

Returns
The result of the asynchronous operation

Definition at line 99 of file future.hpp.

◆ operator=() [1/2]

template<typename T>
Future & helios::async::Future< T >::operator= ( const Future< T > & )
delete

◆ operator=() [2/2]

template<typename T>
Future & helios::async::Future< T >::operator= ( Future< T > && other)
defaultnoexcept

◆ Valid()

template<typename T>
bool helios::async::Future< T >::Valid ( ) const
inlinenodiscard

Checks if the future has a shared state.

A future becomes invalid after Get() is called or if it was default-constructed.

Returns
True if the future is valid (has an associated task), false otherwise

Definition at line 87 of file future.hpp.

◆ Wait()

template<typename T>
void helios::async::Future< T >::Wait ( )
inline

Blocks until the result is available.

Unlike Get(), this doesn't retrieve the result and can be called multiple times.

Definition at line 111 of file future.hpp.

◆ WaitFor()

template<typename T>
requires requires { typename std::chrono::duration<Rep, Period>; }
template<typename Rep, typename Period>
requires requires { typename std::chrono::duration<Rep, Period>; }
std::future_status helios::async::Future< T >::WaitFor ( const std::chrono::duration< Rep, Period > & rel_time) const
inline

Waits for the result to become available for the specified duration.

Template Parameters
RepDuration representation type
PeriodDuration period type
Parameters
rel_timeMaximum time to wait
Returns
Status indicating whether the result is ready, timeout occurred, or task was deferred

Definition at line 119 of file future.hpp.

◆ WaitUntil()

template<typename T>
requires requires { typename std::chrono::time_point<Clock, Duration>; }
template<typename Clock, typename Duration>
requires requires { typename std::chrono::time_point<Clock, Duration>; }
std::future_status helios::async::Future< T >::WaitUntil ( const std::chrono::time_point< Clock, Duration > & abs_time) const
inline

Waits for the result to become available until the specified time point.

Template Parameters
ClockClock type
DurationDuration type
Parameters
abs_timeAbsolute time point to wait until
Returns
Status indicating whether the result is ready, timeout occurred, or task was deferred

Definition at line 128 of file future.hpp.

◆ Executor

template<typename T>
friend class Executor
friend

Definition at line 94 of file future.hpp.

◆ SubTaskGraph

template<typename T>
friend class SubTaskGraph
friend

Definition at line 95 of file future.hpp.