QuantumLibrary
Bloomberg::quantum::ICoroContextBase Interface Referenceabstract

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

#include <quantum_icoro_context_base.h>

Inheritance diagram for Bloomberg::quantum::ICoroContextBase:
Bloomberg::quantum::IContextBase Bloomberg::quantum::ICoroSync Bloomberg::quantum::ICoroContext< RET > Bloomberg::quantum::Context< RET >

Public Types

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

Public Member Functions

virtual void wait (ICoroSync::Ptr sync) const =0
 Waits for the future associated with this context to be ready. More...
 
virtual std::future_status waitFor (ICoroSync::Ptr sync, 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, ICoroSync::Ptr sync) const =0
 Waits for the future in the 'num-th' continuation context to be ready. More...
 
virtual std::future_status waitForAt (int num, ICoroSync::Ptr sync, 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 (ICoroSync::Ptr sync) 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...
 
- Public Member Functions inherited from Bloomberg::quantum::ICoroSync
virtual ~ICoroSync ()=default
 Default virtual destructor. More...
 
virtual void setYieldHandle (Traits::Yield &yield)=0
 Sets the underlying boost::coroutine object so that it can be yielded on. More...
 
virtual Traits::YieldgetYieldHandle ()=0
 Retrieve the underlying boost::coroutine object. More...
 
virtual void yield ()=0
 Explicitly yields this coroutine context. More...
 
virtual std::atomic_int & signal ()=0
 Accessor to the underlying synchronization variable. More...
 
virtual void sleep (const std::chrono::milliseconds &timeMs)=0
 Sleeps the coroutine associated with this context for at least 'timeMs' milliseconds or 'timeUs' microseconds depending on the overload chosen. More...
 
virtual void sleep (const std::chrono::microseconds &timeUs)=0
 

Detailed Description

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

Member Typedef Documentation

◆ Ptr

Member Function Documentation

◆ wait()

virtual void Bloomberg::quantum::ICoroContextBase::wait ( ICoroSync::Ptr  sync) const
pure virtual

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

Parameters
[in]syncPointer to the coroutine synchronization object.
Note
Blocks until the future is ready or until an exception is thrown.

Implemented in Bloomberg::quantum::Context< RET >.

◆ waitAll()

virtual void Bloomberg::quantum::ICoroContextBase::waitAll ( ICoroSync::Ptr  sync) const
pure virtual

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

Parameters
[in]syncPointer to the coroutine synchronization object.
Note
Blocks until all future values are ready. If any future throws, the exception is swallowed.

Implemented in Bloomberg::quantum::Context< RET >.

◆ waitAt()

virtual void Bloomberg::quantum::ICoroContextBase::waitAt ( int  num,
ICoroSync::Ptr  sync 
) 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.
[in]syncPointer to the coroutine synchronization object.
Note
Blocks until the value is ready or an exception is thrown.

Implemented in Bloomberg::quantum::Context< RET >.

◆ waitFor()

virtual std::future_status Bloomberg::quantum::ICoroContextBase::waitFor ( ICoroSync::Ptr  sync,
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]syncPointer to the coroutine synchronization object.
[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 >.

◆ waitForAt()

virtual std::future_status Bloomberg::quantum::ICoroContextBase::waitForAt ( int  num,
ICoroSync::Ptr  sync,
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]syncPointer to the coroutine synchronization object.
[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 >.