BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
Public Member Functions | Friends | List of all members
fc::future< T > Class Template Reference

a placeholder for the result of an asynchronous operation. More...

#include <future.hpp>

Public Member Functions

 future (const typename promise< T >::ptr &p)
 
 future (typename promise< T >::ptr &&p)
 
 future (const future< T > &f)
 
 future ()
 
futureoperator= (future< T > &&f)
 
 operator const T & () const
 
const T & wait (const microseconds &timeout=microseconds::maximum()) const
 
const T & wait_until (const time_point &tp) const
 
bool valid () const
 
bool ready () const
 
bool error () const
 
void cancel (const char *reason FC_CANCELATION_REASON_DEFAULT_ARG) const
 
bool canceled () const
 
void cancel_and_wait (const char *reason FC_CANCELATION_REASON_DEFAULT_ARG)
 
template<typename CompletionHandler >
void on_complete (CompletionHandler &&c)
 

Friends

class thread
 

Detailed Description

template<typename T>
class fc::future< T >

a placeholder for the result of an asynchronous operation.

By calling future<T>::wait() you will block the current fiber until the asynchronous operation completes.

If you would like to use an asynchronous interface instead of the synchronous 'wait' method you could specify a CompletionHandler which is a method that takes two parameters, a const reference to the value and an exception_ptr. If the exception_ptr is set, the value reference is invalid and accessing it is 'undefined'.

Promises have pointer semantics, futures have reference semantics that contain a shared pointer to a promise.

Definition at line 211 of file future.hpp.

Constructor & Destructor Documentation

◆ future() [1/4]

template<typename T >
fc::future< T >::future ( const typename promise< T >::ptr &  p)
inline

Definition at line 213 of file future.hpp.

◆ future() [2/4]

template<typename T >
fc::future< T >::future ( typename promise< T >::ptr &&  p)
inline

Definition at line 214 of file future.hpp.

◆ future() [3/4]

template<typename T >
fc::future< T >::future ( const future< T > &  f)
inline

Definition at line 215 of file future.hpp.

◆ future() [4/4]

template<typename T >
fc::future< T >::future ( )
inline

Definition at line 216 of file future.hpp.

Member Function Documentation

◆ cancel()

template<typename T >
void fc::future< T >::cancel ( const char *reason  FC_CANCELATION_REASON_DEFAULT_ARG) const
inline

Definition at line 248 of file future.hpp.

◆ cancel_and_wait()

template<typename T >
void fc::future< T >::cancel_and_wait ( const char *reason  FC_CANCELATION_REASON_DEFAULT_ARG)
inline

Definition at line 251 of file future.hpp.

◆ canceled()

template<typename T >
bool fc::future< T >::canceled ( ) const
inline

Definition at line 249 of file future.hpp.

◆ error()

template<typename T >
bool fc::future< T >::error ( ) const
inline
Precondition
valid()

Definition at line 246 of file future.hpp.

◆ on_complete()

template<typename T >
template<typename CompletionHandler >
void fc::future< T >::on_complete ( CompletionHandler &&  c)
inline
Precondition
valid()

The given completion handler will be called from some arbitrary thread and should not 'block'. Generally it should post an event or start a new async operation.

Definition at line 274 of file future.hpp.

◆ operator const T &()

template<typename T >
fc::future< T >::operator const T & ( ) const
inline

Definition at line 223 of file future.hpp.

◆ operator=()

template<typename T >
future& fc::future< T >::operator= ( future< T > &&  f)
inline

Definition at line 218 of file future.hpp.

◆ ready()

template<typename T >
bool fc::future< T >::ready ( ) const
inline
Precondition
valid()

Definition at line 243 of file future.hpp.

◆ valid()

template<typename T >
bool fc::future< T >::valid ( ) const
inline

Definition at line 240 of file future.hpp.

◆ wait()

template<typename T >
const T& fc::future< T >::wait ( const microseconds timeout = microseconds::maximum()) const
inline
Precondition
valid()
Postcondition
ready()
Exceptions
timeout

Definition at line 228 of file future.hpp.

◆ wait_until()

template<typename T >
const T& fc::future< T >::wait_until ( const time_point tp) const
inline
Precondition
valid()
Postcondition
ready()
Exceptions
timeout

Definition at line 235 of file future.hpp.

Friends And Related Function Documentation

◆ thread

template<typename T >
friend class thread
friend

Definition at line 278 of file future.hpp.


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