Pyrogenesis  trunk
Public Member Functions | Public Attributes | Static Private Attributes | List of all members
FutureSharedStateDetail::SharedState< ResultType > Class Template Reference

The shared state between futures and packaged state. More...

#include <Future.h>

Inheritance diagram for FutureSharedStateDetail::SharedState< ResultType >:
Inheritance graph
[legend]
Collaboration diagram for FutureSharedStateDetail::SharedState< ResultType >:
Collaboration graph
[legend]

Public Member Functions

 SharedState (std::function< ResultType()> &&func)
 
 m_Func (std::move(func))
 
 ~SharedState ()
 
 SharedState (const SharedState &)=delete
 
 SharedState (SharedState &&)=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...
 
template<typename _ResultType = ResultType>
std::enable_if_t<!std::is_same_v< _ResultType, void >, 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::function< ResultType()> m_Func
 

Static Private Attributes

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

Detailed Description

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

The shared state between futures and packaged state.

Holds all relevant data.

Constructor & Destructor Documentation

◆ SharedState() [1/3]

template<typename ResultType >
FutureSharedStateDetail::SharedState< ResultType >::SharedState ( std::function< ResultType()> &&  func)
inline

◆ ~SharedState()

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

◆ SharedState() [2/3]

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

◆ SharedState() [3/3]

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

Member Function Documentation

◆ Cancel()

template<typename ResultType >
bool FutureSharedStateDetail::SharedState< 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 >
template<typename _ResultType = ResultType>
std::enable_if_t<!std::is_same_v<_ResultType, void>, ResultType> FutureSharedStateDetail::SharedState< ResultType >::GetResult ( )
inline

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

◆ IsDoneOrCanceled()

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

◆ m_Func()

template<typename ResultType >
FutureSharedStateDetail::SharedState< ResultType >::m_Func ( std::move(func)  )
inline

◆ Wait()

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

Member Data Documentation

◆ m_ConditionVariable

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

◆ m_Func

template<typename ResultType >
std::function<ResultType()> FutureSharedStateDetail::SharedState< ResultType >::m_Func

◆ m_Mutex

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

◆ m_Status

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

◆ VoidResult

template<typename ResultType >
constexpr bool FutureSharedStateDetail::SharedState< ResultType >::VoidResult = std::is_same_v<ResultType, void>
staticprivate

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