OnixS C++ CME iLink 3 Binary Order Entry Handler  1.17.0
API Documentation
SharedFuture< T > Class Template Reference

#include <OnixS/CME/iLink3/threading/Future.h>

Public Member Functions

 SharedFuture () noexcept
 SharedFuture (const SharedFuture< T > &other) noexcept
SharedFuture< T > & operator= (const SharedFuture< T > &other) noexcept
 SharedFuture (SharedFuture< T > &&other) noexcept
FutureBaseoperator= (SharedFuture< T > &&other) noexcept
Implementation::FutureGetReturn< T >::Type get () const
void swap (SharedFuture< T > &other) noexcept
void get () const
- Public Member Functions inherited from FutureBase
bool valid () const noexcept
bool is_ready () const
bool has_value () const
bool has_exception () const
std::exception_ptr get_exception_ptr () const
FutureStatus::Enum wait (int timeoutInMs) const


class Implementation::FutureHelper

Additional Inherited Members

- Public Types inherited from FutureBase
enum  { InfiniteTimeout = -1 }
- Protected Member Functions inherited from FutureBase
 FutureBase ()
 FutureBase (const FutureBase &other) noexcept
FutureBaseoperator= (const FutureBase &other) noexcept
 FutureBase (FutureBase &&other) noexcept
FutureBaseoperator= (FutureBase &&other) noexcept
 FutureBase (const System::FutureSharedState *state) noexcept
 FutureBase (const System::FutureSharedState *state, moving_init_t) noexcept
 ~FutureBase () noexcept
void swap (FutureBase &other) noexcept
const void * getValuePtr () const
void getVoid () const

Detailed Description

template<typename T>
class OnixS::CME::iLink3::Threading::SharedFuture< T >

The class template Future provides a mechanism to access the result of asynchronous operations :

  • An asynchronous operation (e.g. created via Promise) can provide a Future object to the creator of that asynchronous operation (e.g. via Promise::get_future).
  • The creator of the asynchronous operation can then use a variety of methods to query, wait for, or extract a value from Future. These methods may block if the asynchronous operation has not yet provided a value.
  • When the asynchronous operation is ready to send a result to the creator, it can do so by modifying shared state (e.g. via Promise::set_value) that is linked to the creator's Future.

Future is the synchronization object constructed around the receiving end of the Promise channel. It allows for the separation of the initiation of an operation and the act of waiting for its result.

Future is copiable and multiple SharedFuture objects may refer to the same shared state.

Unlike std::future, this implementation has an extended API, allowing you to query the state of SharedFuture. The internal implementation is lock-free; therefore, setting and polling states do not lead to blocking of threads and/or switching of an execution context.

Access to the same shared state from multiple threads is safe if each thread does it through its own copy of a SharedFuture object.
See also
http://en.cppreference.com/w/cpp/thread/shared_future .

Definition at line 189 of file Future.h.

Constructor & Destructor Documentation

SharedFuture ( )

Definition at line 192 of file Future.h.

SharedFuture ( const SharedFuture< T > &  other)

Copy constructor.

Definition at line 196 of file Future.h.

SharedFuture ( SharedFuture< T > &&  other)

Definition at line 207 of file Future.h.

Member Function Documentation

Implementation::FutureGetReturn<T>::Type get ( ) const

Returns the result.

If the result is not ready, the method will block. When completes, it either returns a value or throws an exception.

This method waits until the Future has a valid result and retrieves it. It effectively calls wait() in order to wait for the result.

Ifan exception was stored in the shared state referenced by this Future (e.g. via a call to Promise::set_exception()) then that exception will be thrown.

Definition at line 222 of file Future.h.

void get ( ) const

Definition at line 244 of file Future.h.

SharedFuture<T>& operator= ( const SharedFuture< T > &  other)

Copy assignment.

Definition at line 200 of file Future.h.

FutureBase& operator= ( SharedFuture< T > &&  other)

Definition at line 210 of file Future.h.

void swap ( SharedFuture< T > &  other)

swaps two SharedFuture objects

Definition at line 227 of file Future.h.

Friends And Related Function Documentation

friend class Implementation::FutureHelper

Definition at line 240 of file Future.h.

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