Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
FutureSharedStateDetail::Receiver< ResultType > Class Template Reference

Responsible for syncronization between the task and the receiving thread. More...

#include <Future.h>

Public Member Functions

 Receiver ()=default
 
 ~Receiver ()
 
 Receiver (const Receiver &)=delete
 
 Receiver (Receiver &&)=delete
 
bool IsDoneOrCanceled () const
 
void Wait ()
 
bool Cancel ()
 If the task is pending, cancel it: the status becomes CANCELED and if the task was completed, the result is destroyed. More...
 
ResultType GetResult ()
 Move the result away from the shared state, mark the future invalid. More...
 

Public Attributes

std::atomic< Statusm_Status = Status::PENDING
 
std::mutex m_Mutex
 
std::condition_variable m_ConditionVariable
 
std::tuple< ResultHolder< ResultType >, std::exception_ptr > m_Outcome
 

Static Private Attributes

static constexpr bool VoidResult = std::is_same_v<ResultType, void>
 

Detailed Description

template<typename ResultType>
class FutureSharedStateDetail::Receiver< ResultType >

Responsible for syncronization between the task and the receiving thread.

Constructor & Destructor Documentation

◆ Receiver() [1/3]

template<typename ResultType >
FutureSharedStateDetail::Receiver< ResultType >::Receiver ( )
default

◆ ~Receiver()

template<typename ResultType >
FutureSharedStateDetail::Receiver< ResultType >::~Receiver ( )
inline

◆ Receiver() [2/3]

template<typename ResultType >
FutureSharedStateDetail::Receiver< ResultType >::Receiver ( const Receiver< ResultType > &  )
delete

◆ Receiver() [3/3]

template<typename ResultType >
FutureSharedStateDetail::Receiver< ResultType >::Receiver ( Receiver< ResultType > &&  )
delete

Member Function Documentation

◆ Cancel()

template<typename ResultType >
bool FutureSharedStateDetail::Receiver< ResultType >::Cancel ( )
inline

If the task is pending, cancel it: the status becomes CANCELED and if the task was completed, the result is destroyed.

Returns
true if the task was indeed cancelled, false otherwise (the task is running or already done).

◆ GetResult()

template<typename ResultType >
ResultType FutureSharedStateDetail::Receiver< ResultType >::GetResult ( )
inline

Move the result away from the shared state, mark the future invalid.

◆ IsDoneOrCanceled()

template<typename ResultType >
bool FutureSharedStateDetail::Receiver< ResultType >::IsDoneOrCanceled ( ) const
inline

◆ Wait()

template<typename ResultType >
void FutureSharedStateDetail::Receiver< ResultType >::Wait ( )
inline

Member Data Documentation

◆ m_ConditionVariable

template<typename ResultType >
std::condition_variable FutureSharedStateDetail::Receiver< ResultType >::m_ConditionVariable

◆ m_Mutex

template<typename ResultType >
std::mutex FutureSharedStateDetail::Receiver< ResultType >::m_Mutex

◆ m_Outcome

template<typename ResultType >
std::tuple<ResultHolder<ResultType>, std::exception_ptr> FutureSharedStateDetail::Receiver< ResultType >::m_Outcome
Initial value:
{std::nullopt,
std::exception_ptr{}}

◆ m_Status

template<typename ResultType >
std::atomic<Status> FutureSharedStateDetail::Receiver< ResultType >::m_Status = Status::PENDING

◆ VoidResult

template<typename ResultType >
constexpr bool FutureSharedStateDetail::Receiver< ResultType >::VoidResult = std::is_same_v<ResultType, void>
staticconstexprprivate

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