OnixS C++ CME MDP Premium Market Data Handler 5.10.3
Users' manual and API documentation
Loading...
Searching...
No Matches
SharedFuture< T > Class Template Reference

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

Public Member Functions

 SharedFuture () noexcept=default
 SharedFuture (const SharedFuture &other) noexcept=default
SharedFutureoperator= (const SharedFuture &other) noexcept=default
 SharedFuture (SharedFuture &&other) noexcept=default
SharedFutureoperator= (SharedFuture &&other) noexcept=default
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
std::future_status wait (int timeoutInMs=InfiniteTimeout) const

Friends

class Implementation::FutureHelper

Additional Inherited Members

Public Types inherited from FutureBase
enum  
Protected Member Functions inherited from FutureBase
 FutureBase () noexcept=default
 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::MDH::Threading::SharedFuture< T >

Represents the result of an asynchronous operation.

A producer creates a shared state through the internal system future/promise implementation and exposes it through SharedFuture. A consumer can then check readiness, wait for completion, retrieve the value, or observe a stored exception. These operations may block or throw depending on the state.

SharedFuture is copiable, and multiple instances may refer to the same shared state. Access to the same shared state from multiple threads is safe if each thread does it through its own copy of a SharedFuture object.

Reference result types are intentionally not supported by this public wrapper.

Definition at line 159 of file Future.h.

Constructor & Destructor Documentation

◆ SharedFuture() [1/3]

template<typename T>
SharedFuture ( )
defaultnoexcept

◆ SharedFuture() [2/3]

template<typename T>
SharedFuture ( const SharedFuture< T > & other)
defaultnoexcept

Copy constructor.

◆ SharedFuture() [3/3]

template<typename T>
SharedFuture ( SharedFuture< T > && other)
defaultnoexcept

Member Function Documentation

◆ get() [1/2]

template<typename T>
Implementation::FutureGetReturn< T >::Type get ( ) const
inline

Waits for completion and returns the stored value.

The returned reference remains valid while the shared state remains alive. If the shared state stores an exception, this method rethrows that exception.

Exceptions
std::logic_errorif this instance does not refer to a shared state.

Definition at line 182 of file Future.h.

◆ get() [2/2]

void get ( ) const
inline

Waits for completion of a void result and rethrows a stored exception, if any.

Definition at line 212 of file Future.h.

◆ operator=() [1/2]

template<typename T>
SharedFuture & operator= ( const SharedFuture< T > & other)
defaultnoexcept

Copy assignment.

◆ operator=() [2/2]

template<typename T>
SharedFuture & operator= ( SharedFuture< T > && other)
defaultnoexcept

◆ swap()

template<typename T>
void swap ( SharedFuture< T > & other)
inlinenoexcept

Swaps two SharedFuture objects.

Definition at line 188 of file Future.h.

◆ Implementation::FutureHelper

template<typename T>
friend class Implementation::FutureHelper
friend

Definition at line 204 of file Future.h.