QuantumLibrary
Bloomberg::quantum::ICoroSync Interface Referenceabstract

Provides an interface to facilitate 'implicit' coroutine yielding within other primitives such as mutexes and condition variables or to allow 'explicit' cooperative yielding by the user. More...

#include <quantum_icoro_sync.h>

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

Public Types

using Ptr = std::shared_ptr< ICoroSync >
 

Public Member Functions

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

Provides an interface to facilitate 'implicit' coroutine yielding within other primitives such as mutexes and condition variables or to allow 'explicit' cooperative yielding by the user.

Note
This class is used internally and as such should not be accessed directly.

Member Typedef Documentation

◆ Ptr

Constructor & Destructor Documentation

◆ ~ICoroSync()

virtual Bloomberg::quantum::ICoroSync::~ICoroSync ( )
virtualdefault

Default virtual destructor.

Member Function Documentation

◆ getYieldHandle()

virtual Traits::Yield& Bloomberg::quantum::ICoroSync::getYieldHandle ( )
pure virtual

Retrieve the underlying boost::coroutine object.

Returns
The associated boost::coroutine object held by this class.
Exceptions
Ifthe underlying boost::coroutine is not set.

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

◆ setYieldHandle()

virtual void Bloomberg::quantum::ICoroSync::setYieldHandle ( Traits::Yield yield)
pure virtual

Sets the underlying boost::coroutine object so that it can be yielded on.

Parameters
[in]yieldReference to the boost::coroutine object.

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

◆ signal()

virtual std::atomic_int& Bloomberg::quantum::ICoroSync::signal ( )
pure virtual

Accessor to the underlying synchronization variable.

Returns
An atomic integer used to synchronize with other primitive types.

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

◆ sleep() [1/2]

virtual void Bloomberg::quantum::ICoroSync::sleep ( const std::chrono::milliseconds &  timeMs)
pure virtual

Sleeps the coroutine associated with this context for at least 'timeMs' milliseconds or 'timeUs' microseconds depending on the overload chosen.

Parameters
[in]timeMs/timeUsTime to sleep.
Note
This method yields the coroutine until the timer has expired. Depending on the coroutine load on the particular running thread, this method may sleep longer.

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

◆ sleep() [2/2]

virtual void Bloomberg::quantum::ICoroSync::sleep ( const std::chrono::microseconds &  timeUs)
pure virtual

◆ yield()

virtual void Bloomberg::quantum::ICoroSync::yield ( )
pure virtual

Explicitly yields this coroutine context.

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