CatapultServer  v0.5.0.1 (Elephant)
catapult::thread::detail::shared_state< T > Class Template Reference

Shared state that is shared between a promise and a future. More...

Inheritance diagram for catapult::thread::detail::shared_state< T >:
Collaboration diagram for catapult::thread::detail::shared_state< T >:

Public Member Functions

 shared_state ()
 Creates an incomplete shared state. More...
 
bool is_ready () const
 Returns true if this shared state has completed and get will not block. More...
 
T get ()
 Returns the result of this shared state and blocks until the result is available. More...
 
void set_value (T &&value)
 Sets the result of this shared state to value. More...
 
void set_exception (std::exception_ptr pException)
 Sets the result of this shared state to pException. More...
 
void set_continuation (const ContinuationFunc &continuation)
 Configures continuation to run at the completion of this shared state. More...
 

Private Types

enum  future_status { future_status::pending, future_status::completed_success, future_status::completed_error }
 
using ContinuationFunc = consumer< const std::shared_ptr< shared_state< T > >>
 

Private Member Functions

void assert_pending () const
 
void signal (future_status status)
 
void invokeContinuation ()
 
- Private Member Functions inherited from catapult::utils::NonCopyable
constexpr NonCopyable ()=default
 Default constructor. More...
 
 ~NonCopyable ()=default
 Default destructor. More...
 
 NonCopyable (const NonCopyable &)=delete
 Disabled copy constructor. More...
 
NonCopyable & operator= (const NonCopyable &)=delete
 Disabled assignment operator. More...
 

Private Attributes

std::atomic< future_status > m_status
 
T m_value
 
std::exception_ptr m_pException
 
ContinuationFunc m_continuation
 
std::condition_variable m_condition
 
std::mutex m_mutex
 

Detailed Description

template<typename T>
class catapult::thread::detail::shared_state< T >

Shared state that is shared between a promise and a future.

Member Typedef Documentation

◆ ContinuationFunc

template<typename T >
using catapult::thread::detail::shared_state< T >::ContinuationFunc = consumer<const std::shared_ptr<shared_state<T> >>
private

Member Enumeration Documentation

◆ future_status

template<typename T >
enum catapult::thread::detail::shared_state::future_status
strongprivate
Enumerator
pending 
completed_success 
completed_error 

Constructor & Destructor Documentation

◆ shared_state()

template<typename T >
catapult::thread::detail::shared_state< T >::shared_state ( )
inline

Creates an incomplete shared state.

Member Function Documentation

◆ assert_pending()

template<typename T >
void catapult::thread::detail::shared_state< T >::assert_pending ( ) const
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get()

template<typename T >
T catapult::thread::detail::shared_state< T >::get ( )
inline

Returns the result of this shared state and blocks until the result is available.

◆ invokeContinuation()

template<typename T >
void catapult::thread::detail::shared_state< T >::invokeContinuation ( )
inlineprivate
Here is the caller graph for this function:

◆ is_ready()

template<typename T >
bool catapult::thread::detail::shared_state< T >::is_ready ( ) const
inline

Returns true if this shared state has completed and get will not block.

Here is the caller graph for this function:

◆ set_continuation()

template<typename T >
void catapult::thread::detail::shared_state< T >::set_continuation ( const ContinuationFunc &  continuation)
inline

Configures continuation to run at the completion of this shared state.

Here is the call graph for this function:

◆ set_exception()

template<typename T >
void catapult::thread::detail::shared_state< T >::set_exception ( std::exception_ptr  pException)
inline

Sets the result of this shared state to pException.

Here is the call graph for this function:

◆ set_value()

template<typename T >
void catapult::thread::detail::shared_state< T >::set_value ( T &&  value)
inline

Sets the result of this shared state to value.

Here is the call graph for this function:

◆ signal()

template<typename T >
void catapult::thread::detail::shared_state< T >::signal ( future_status  status)
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_condition

template<typename T >
std::condition_variable catapult::thread::detail::shared_state< T >::m_condition
private

◆ m_continuation

template<typename T >
ContinuationFunc catapult::thread::detail::shared_state< T >::m_continuation
private

◆ m_mutex

template<typename T >
std::mutex catapult::thread::detail::shared_state< T >::m_mutex
private

◆ m_pException

template<typename T >
std::exception_ptr catapult::thread::detail::shared_state< T >::m_pException
private

◆ m_status

template<typename T >
std::atomic<future_status> catapult::thread::detail::shared_state< T >::m_status
private

◆ m_value

template<typename T >
T catapult::thread::detail::shared_state< T >::m_value
private

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