QuantumLibrary
Bloomberg::quantum::ICoroPromise< PROMISE, T > Interface Template Referenceabstract

Exposes methods to access and manipulate a coroutine-compatible promise. More...

#include <quantum_icoro_promise.h>

Inheritance diagram for Bloomberg::quantum::ICoroPromise< PROMISE, T >:
Bloomberg::quantum::Traits::DerivedFrom< PROMISE< T >, ICoroPromise< PROMISE, T >, IPromiseBase >

Public Types

using ContextTag = CoroContextTag
 
using Ptr = std::shared_ptr< ICoroPromise< PROMISE, T > >
 
using Impl = PROMISE< T >
 

Public Member Functions

 ICoroPromise (Impl *derived)
 Constructor. More...
 
virtual CoroFuturePtr< T > getICoroFuture () const =0
 Get the associated coroutine future. More...
 
template<class V , class = NonBufferType<T,V>>
int set (ICoroSync::Ptr sync, V &&value)
 Set the promised value. More...
 
template<class V , class = BufferType<T,V>>
void push (ICoroSync::Ptr sync, V &&value)
 Push a single value into the promise buffer. More...
 
template<class V = T, class = BufferRetType<V>>
int closeBuffer ()
 Close a promise buffer. More...
 
- Public Member Functions inherited from Bloomberg::quantum::Traits::DerivedFrom< PROMISE< T >, ICoroPromise< PROMISE, T >, IPromiseBase >
virtual ~DerivedFrom ()=default
 
 operator IPromiseBase * ()
 
 operator IPromiseBase & ()
 

Detailed Description

template<template< class > class PROMISE, class T>
interface Bloomberg::quantum::ICoroPromise< PROMISE, T >

Exposes methods to access and manipulate a coroutine-compatible promise.

Template Parameters
PROMISEThe derived promise (concrete type).
TThe type of value contained in this promise.

Member Typedef Documentation

◆ ContextTag

template<template< class > class PROMISE, class T>
using Bloomberg::quantum::ICoroPromise< PROMISE, T >::ContextTag = CoroContextTag

◆ Impl

template<template< class > class PROMISE, class T>
using Bloomberg::quantum::ICoroPromise< PROMISE, T >::Impl = PROMISE<T>

◆ Ptr

template<template< class > class PROMISE, class T>
using Bloomberg::quantum::ICoroPromise< PROMISE, T >::Ptr = std::shared_ptr<ICoroPromise<PROMISE, T> >

Constructor & Destructor Documentation

◆ ICoroPromise()

template<template< class > class PROMISE, class T>
Bloomberg::quantum::ICoroPromise< PROMISE, T >::ICoroPromise ( Impl derived)
inline

Constructor.

Parameters
[in]derivedA pointer to the concrete implementation of this class.
Note
The constructor parameter is only used for template deduction at compile time.

Member Function Documentation

◆ closeBuffer()

template<template< class > class PROMISE, class T >
template<class V , class >
int Bloomberg::quantum::ICoroPromise< PROMISE, T >::closeBuffer ( )

Close a promise buffer.

Template Parameters
BUFRepresents a class of type Buffer.
Note
Once closed no more Pushes can be made into the buffer. The corresponding future can still Pull values until the buffer is empty.
Returns
0 on success.

◆ getICoroFuture()

template<template< class > class PROMISE, class T>
virtual CoroFuturePtr<T> Bloomberg::quantum::ICoroPromise< PROMISE, T >::getICoroFuture ( ) const
pure virtual

Get the associated coroutine future.

Returns
An interface to the associated future object sharing a common state.

Implemented in Bloomberg::quantum::Promise< T >.

◆ push()

template<template< class > class PROMISE, class T >
template<class V , class >
void Bloomberg::quantum::ICoroPromise< PROMISE, T >::push ( ICoroSync::Ptr  sync,
V &&  value 
)

Push a single value into the promise buffer.

Template Parameters
BUFRepresents a class of type Buffer.
VThe type of value contained in Buffer.
Parameters
[in]syncA pointer to a coroutine synchronization context.
[in]valueValue to push at the end of the buffer.
Note
Method available for buffered futures only. Once the buffer is closed, no more Push operations are allowed.

◆ set()

template<template< class > class PROMISE, class T >
template<class V , class >
int Bloomberg::quantum::ICoroPromise< PROMISE, T >::set ( ICoroSync::Ptr  sync,
V &&  value 
)

Set the promised value.

Template Parameters
VThe type of the value. Must be implicitly deduced by the compiler and should always be == T.
Parameters
[in]syncA pointer to a coroutine synchronization context.
[in]valueA reference to the value (l-value or r-value).
Returns
0 on success