QuantumLibrary
Bloomberg::quantum::IThreadContextBase Interface Referenceabstract

Exposes methods to manipulate the thread context, especially future wait methods. More...

#include <quantum_ithread_context_base.h>

Inheritance diagram for Bloomberg::quantum::IThreadContextBase:
Bloomberg::quantum::IContextBase Bloomberg::quantum::IThreadContext< RET > Bloomberg::quantum::Context< RET >

Public Types

using Ptr = std::shared_ptr< IThreadContextBase >
 
- Public Types inherited from Bloomberg::quantum::IContextBase
using Ptr = std::shared_ptr< IContextBase >
 

Public Member Functions

virtual void wait () const =0
 Waits for the future associated with this context to be ready. More...
 
virtual std::future_status waitFor (std::chrono::milliseconds timeMs) const =0
 Waits for the future associated with this context to be ready for a maximum of 'timeMs' milliseconds. More...
 
virtual void waitAt (int num) const =0
 Waits for the future in the 'num-th' continuation context to be ready. More...
 
virtual std::future_status waitForAt (int num, std::chrono::milliseconds timeMs) const =0
 Waits for the future in the 'num-th' continuation context to be ready for a maximum of 'timeMs' milliseconds. More...
 
virtual void waitAll () const =0
 Wait for all the futures in the continuation chain to be ready. More...
 
- Public Member Functions inherited from Bloomberg::quantum::IContextBase
virtual ~IContextBase ()=default
 Virtual destructor. More...
 
virtual bool valid () const =0
 Determines if the future object associated with this context has a valid shared state with the corresponding promise. More...
 
virtual bool validAt (int num) const =0
 Determines if the future object associated with the 'num'-th continuation context is still valid. More...
 
virtual int setException (std::exception_ptr ex)=0
 Set an exception in the promise associated with the current IThreadContext or ICoroContext. More...
 

Detailed Description

Exposes methods to manipulate the thread context, especially future wait methods.

Member Typedef Documentation

◆ Ptr

Member Function Documentation

◆ wait()

virtual void Bloomberg::quantum::IThreadContextBase::wait ( ) const
pure virtual

Waits for the future associated with this context to be ready.

Note
Blocks until the future is ready or until an exception is thrown.

Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::IThreadContext< RET >.

◆ waitAll()

virtual void Bloomberg::quantum::IThreadContextBase::waitAll ( ) const
pure virtual

Wait for all the futures in the continuation chain to be ready.

Note
Blocks until all future values are ready. If any future throws, the exception is swallowed.

Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::IThreadContext< RET >.

◆ waitAt()

virtual void Bloomberg::quantum::IThreadContextBase::waitAt ( int  num) const
pure virtual

Waits for the future in the 'num-th' continuation context to be ready.

Allowed range for num is [-1, total_continuations). -1 is equivalent of calling wait() or waitAt(total_continuations-1) on the last context in the chain (i.e. the context which is returned via end()). Position 0 represents the first future in the chain.

Parameters
[in]numThe number indicating which future to wait on.
Note
Blocks until the value is ready or an exception is thrown.

Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::IThreadContext< RET >.

◆ waitFor()

virtual std::future_status Bloomberg::quantum::IThreadContextBase::waitFor ( std::chrono::milliseconds  timeMs) const
pure virtual

Waits for the future associated with this context to be ready for a maximum of 'timeMs' milliseconds.

Parameters
[in]timeMsThe maximum amount of milliseconds to wait until the future value becomes ready.
Returns
'ready' if value was posted before duration expired or 'timeout' otherwise.
Note
Blocks until the value is ready, until 'timeMs' duration expires or until an exception is thrown.

Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::IThreadContext< RET >.

◆ waitForAt()

virtual std::future_status Bloomberg::quantum::IThreadContextBase::waitForAt ( int  num,
std::chrono::milliseconds  timeMs 
) const
pure virtual

Waits for the future in the 'num-th' continuation context to be ready for a maximum of 'timeMs' milliseconds.

Allowed range for num is [-1, total_continuations). -1 is equivalent of calling wait() or waitAt(total_continuations-1) on the last context in the chain (i.e. the context which is returned via end()). Position 0 represents the first future in the chain.

Parameters
[in]numThe number indicating which future to wait on.
[in]timeMsThe maximum amount of milliseconds to wait until the future value becomes ready.
Returns
'ready' if value was posted before duration expired or 'timeout' otherwise.
Note
Blocks until the value is ready, until 'timeMs' duration expires or until an exception is thrown.

Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::IThreadContext< RET >.