QuantumLibrary
|
Exposes methods to manipulate the coroutine context. More...
#include <quantum_icoro_context.h>
Public Types | |
using | ContextTag = CoroContextTag |
using | Ptr = std::shared_ptr< ICoroContext< RET > > |
using | Impl = Context< RET > |
![]() | |
using | Ptr = std::shared_ptr< ICoroContextBase > |
![]() | |
using | Ptr = std::shared_ptr< IContextBase > |
![]() | |
using | Ptr = std::shared_ptr< ICoroSync > |
Public Member Functions | |
template<class V = RET> | |
NonBufferRetType< V > | get (ICoroSync::Ptr sync) |
Get the future value associated with this context. More... | |
template<class V = RET> | |
const NonBufferRetType< V > & | getRef (ICoroSync::Ptr sync) const |
Get a reference the future value associated with this context. More... | |
template<class OTHER_RET > | |
NonBufferRetType< OTHER_RET > | getPrev () |
Get the future value associated with the previous coroutine context in the continuation chain. More... | |
template<class OTHER_RET > | |
const NonBufferRetType< OTHER_RET > & | getPrevRef () |
Get a reference to future value associated with the previous coroutine context in the continuation chain. More... | |
template<class OTHER_RET > | |
NonBufferRetType< OTHER_RET > | getAt (int num, ICoroSync::Ptr sync) |
Get the future value from the 'num-th' continuation context. More... | |
template<class OTHER_RET > | |
const NonBufferRetType< OTHER_RET > & | getRefAt (int num, ICoroSync::Ptr sync) const |
Get a reference to the future value from the 'num-th' continuation context. More... | |
template<class V , class = NonBufferType<RET,V>> | |
int | set (V &&value) |
Set the promised value associated with this context. More... | |
template<class V , class = BufferType<RET,V>> | |
void | push (V &&value) |
Push a single value into the promise buffer. More... | |
template<class V = RET> | |
BufferRetType< V > | pull (ICoroSync::Ptr sync, bool &isBufferClosed) |
Pull a single value from the future buffer. More... | |
template<class V = RET, class = BufferRetType<V>> | |
int | closeBuffer () |
Close a promise buffer. More... | |
int | getNumCoroutineThreads () const |
Returns the number of underlying coroutine threads as specified in the dispatcher constructor. If -1 was passed than this number essentially indicates the number of cores. More... | |
int | getNumIoThreads () const |
Returns the number of underlying IO threads as specified in the dispatcher constructor. More... | |
const std::pair< int, int > & | getCoroQueueIdRangeForAny () const |
Gets the range [minQueueId, maxQueueId] of coroutine queueIds covered by IQueue::QueueId::Any by the Dispatcher. More... | |
template<class OTHER_RET = int, class FUNC , class ... ARGS> | |
ICoroContext< OTHER_RET >::Ptr | post (FUNC &&func, ARGS &&... args) |
Post a coroutine to run asynchronously. More... | |
template<class OTHER_RET = int, class FUNC , class ... ARGS> | |
ICoroContext< OTHER_RET >::Ptr | post (int queueId, bool isHighPriority, FUNC &&func, ARGS &&... args) |
Post a coroutine to run asynchronously. More... | |
template<class OTHER_RET = int, class FUNC , class ... ARGS> | |
ICoroContext< OTHER_RET >::Ptr | postFirst (FUNC &&func, ARGS &&... args) |
Posts a coroutine to run asynchronously. More... | |
template<class OTHER_RET = int, class FUNC , class ... ARGS> | |
ICoroContext< OTHER_RET >::Ptr | postFirst (int queueId, bool isHighPriority, FUNC &&func, ARGS &&... args) |
Posts a coroutine to run asynchronously. More... | |
template<class OTHER_RET = int, class FUNC , class ... ARGS> | |
ICoroContext< OTHER_RET >::Ptr | then (FUNC &&func, ARGS &&... args) |
Posts a coroutine to run asynchronously. More... | |
template<class OTHER_RET = int, class FUNC , class ... ARGS> | |
ICoroContext< OTHER_RET >::Ptr | onError (FUNC &&func, ARGS &&... args) |
Posts a coroutine to run asynchronously. This is the error handler for a continuation chain and acts as as a 'catch' clause. More... | |
template<class OTHER_RET = int, class FUNC , class ... ARGS> | |
ICoroContext< OTHER_RET >::Ptr | finally (FUNC &&func, ARGS &&... args) |
Posts a coroutine to run asynchronously. This coroutine is always guaranteed to run. More... | |
Ptr | end () |
This is the last method in a continuation chain. More... | |
template<class OTHER_RET = int, class FUNC , class ... ARGS> | |
CoroFuturePtr< OTHER_RET > | postAsyncIo (FUNC &&func, ARGS &&... args) |
Posts an IO method to run asynchronously on the IO thread pool. More... | |
template<class OTHER_RET = int, class FUNC , class ... ARGS> | |
CoroFuturePtr< OTHER_RET > | postAsyncIo (int queueId, bool isHighPriority, FUNC &&func, ARGS &&... args) |
Posts an IO function to run asynchronously on the IO thread pool. More... | |
template<class OTHER_RET = int, class INPUT_IT , class = Traits::IsInputIterator<INPUT_IT>> | |
ICoroContext< std::vector< OTHER_RET > >::Ptr | forEach (INPUT_IT first, INPUT_IT last, Functions::ForEachFunc< OTHER_RET, INPUT_IT > func) |
Applies the given unary function to all the elements in the range [first,last). This function runs in parallel. More... | |
template<class OTHER_RET = int, class INPUT_IT > | |
ICoroContext< std::vector< OTHER_RET > >::Ptr | forEach (INPUT_IT first, size_t num, Functions::ForEachFunc< OTHER_RET, INPUT_IT > func) |
Applies the given unary function to all the elements in the range [first,first+num). This function runs in parallel. More... | |
template<class OTHER_RET = int, class INPUT_IT , class = Traits::IsInputIterator<INPUT_IT>> | |
ICoroContext< std::vector< std::vector< OTHER_RET > > >::Ptr | forEachBatch (INPUT_IT first, INPUT_IT last, Functions::ForEachFunc< OTHER_RET, INPUT_IT > func) |
Applies the given unary function to all the elements in the range [first,last). This function runs serially with respect to other functions in the same batch. More... | |
template<class OTHER_RET = int, class INPUT_IT > | |
ICoroContext< std::vector< std::vector< OTHER_RET > > >::Ptr | forEachBatch (INPUT_IT first, size_t num, Functions::ForEachFunc< OTHER_RET, INPUT_IT > func) |
Applies the given unary function to all the elements in the range [first,last). This function runs serially with respect to other functions in the same batch. More... | |
template<class KEY , class MAPPED_TYPE , class REDUCED_TYPE , class INPUT_IT , class = Traits::IsInputIterator<INPUT_IT>> | |
ICoroContext< std::map< KEY, REDUCED_TYPE > >::Ptr | mapReduce (INPUT_IT first, INPUT_IT last, Functions::MapFunc< KEY, MAPPED_TYPE, INPUT_IT > mapper, Functions::ReduceFunc< KEY, MAPPED_TYPE, REDUCED_TYPE > reducer) |
Implementation of map-reduce functionality. More... | |
template<class KEY , class MAPPED_TYPE , class REDUCED_TYPE , class INPUT_IT > | |
ICoroContext< std::map< KEY, REDUCED_TYPE > >::Ptr | mapReduce (INPUT_IT first, size_t num, Functions::MapFunc< KEY, MAPPED_TYPE, INPUT_IT > mapper, Functions::ReduceFunc< KEY, MAPPED_TYPE, REDUCED_TYPE > reducer) |
Same as mapReduce() but takes a length as second argument in case INPUT_IT is not a random access iterator. More... | |
template<class KEY , class MAPPED_TYPE , class REDUCED_TYPE , class INPUT_IT , class = Traits::IsInputIterator<INPUT_IT>> | |
ICoroContext< std::map< KEY, REDUCED_TYPE > >::Ptr | mapReduceBatch (INPUT_IT first, INPUT_IT last, Functions::MapFunc< KEY, MAPPED_TYPE, INPUT_IT > mapper, Functions::ReduceFunc< KEY, MAPPED_TYPE, REDUCED_TYPE > reducer) |
This version of mapReduce() runs both the mapper and the reducer functions in batches for improved performance. This should be used in the case where the functions are more CPU intensive with little or no IO. More... | |
template<class KEY , class MAPPED_TYPE , class REDUCED_TYPE , class INPUT_IT > | |
ICoroContext< std::map< KEY, REDUCED_TYPE > >::Ptr | mapReduceBatch (INPUT_IT first, size_t num, Functions::MapFunc< KEY, MAPPED_TYPE, INPUT_IT > mapper, Functions::ReduceFunc< KEY, MAPPED_TYPE, REDUCED_TYPE > reducer) |
Same as mapReduceBatch() but takes a length as second argument in case INPUT_IT is not a random access iterator. More... | |
template<class OTHER_RET , class FUNC , class ... ARGS> | |
CoroContextPtr< OTHER_RET > | post (FUNC &&func, ARGS &&... args) |
template<class OTHER_RET , class FUNC , class ... ARGS> | |
CoroContextPtr< OTHER_RET > | post (int queueId, bool isHighPriority, FUNC &&func, ARGS &&... args) |
template<class OTHER_RET , class FUNC , class ... ARGS> | |
CoroContextPtr< OTHER_RET > | postFirst (FUNC &&func, ARGS &&... args) |
template<class OTHER_RET , class FUNC , class ... ARGS> | |
CoroContextPtr< OTHER_RET > | postFirst (int queueId, bool isHighPriority, FUNC &&func, ARGS &&... args) |
template<class OTHER_RET , class FUNC , class ... ARGS> | |
CoroContextPtr< OTHER_RET > | then (FUNC &&func, ARGS &&... args) |
template<class OTHER_RET , class FUNC , class ... ARGS> | |
CoroContextPtr< OTHER_RET > | onError (FUNC &&func, ARGS &&... args) |
template<class OTHER_RET , class FUNC , class ... ARGS> | |
CoroContextPtr< OTHER_RET > | finally (FUNC &&func, ARGS &&... args) |
template<class OTHER_RET , class INPUT_IT , class > | |
CoroContextPtr< std::vector< OTHER_RET > > | forEach (INPUT_IT first, INPUT_IT last, Functions::ForEachFunc< OTHER_RET, INPUT_IT > func) |
template<class OTHER_RET , class INPUT_IT > | |
CoroContextPtr< std::vector< OTHER_RET > > | forEach (INPUT_IT first, size_t num, Functions::ForEachFunc< OTHER_RET, INPUT_IT > func) |
template<class OTHER_RET , class INPUT_IT , class > | |
CoroContextPtr< std::vector< std::vector< OTHER_RET > > > | forEachBatch (INPUT_IT first, INPUT_IT last, Functions::ForEachFunc< OTHER_RET, INPUT_IT > func) |
template<class OTHER_RET , class INPUT_IT > | |
CoroContextPtr< std::vector< std::vector< OTHER_RET > > > | forEachBatch (INPUT_IT first, size_t num, Functions::ForEachFunc< OTHER_RET, INPUT_IT > func) |
template<class KEY , class MAPPED_TYPE , class REDUCED_TYPE , class INPUT_IT , class > | |
CoroContextPtr< std::map< KEY, REDUCED_TYPE > > | mapReduce (INPUT_IT first, INPUT_IT last, Functions::MapFunc< KEY, MAPPED_TYPE, INPUT_IT > mapper, Functions::ReduceFunc< KEY, MAPPED_TYPE, REDUCED_TYPE > reducer) |
template<class KEY , class MAPPED_TYPE , class REDUCED_TYPE , class INPUT_IT > | |
CoroContextPtr< std::map< KEY, REDUCED_TYPE > > | mapReduce (INPUT_IT first, size_t num, Functions::MapFunc< KEY, MAPPED_TYPE, INPUT_IT > mapper, Functions::ReduceFunc< KEY, MAPPED_TYPE, REDUCED_TYPE > reducer) |
template<class KEY , class MAPPED_TYPE , class REDUCED_TYPE , class INPUT_IT , class > | |
CoroContextPtr< std::map< KEY, REDUCED_TYPE > > | mapReduceBatch (INPUT_IT first, INPUT_IT last, Functions::MapFunc< KEY, MAPPED_TYPE, INPUT_IT > mapper, Functions::ReduceFunc< KEY, MAPPED_TYPE, REDUCED_TYPE > reducer) |
template<class KEY , class MAPPED_TYPE , class REDUCED_TYPE , class INPUT_IT > | |
CoroContextPtr< std::map< KEY, REDUCED_TYPE > > | mapReduceBatch (INPUT_IT first, size_t num, Functions::MapFunc< KEY, MAPPED_TYPE, INPUT_IT > mapper, Functions::ReduceFunc< KEY, MAPPED_TYPE, REDUCED_TYPE > reducer) |
![]() | |
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... | |
![]() | |
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... | |
![]() | |
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::Yield & | getYieldHandle ()=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 |
Exposes methods to manipulate the coroutine context.
RET | The type of value returned via the promise associated with this context. |
using Bloomberg::quantum::ICoroContext< RET >::ContextTag = CoroContextTag |
using Bloomberg::quantum::ICoroContext< RET >::Impl = Context<RET> |
using Bloomberg::quantum::ICoroContext< RET >::Ptr = std::shared_ptr<ICoroContext<RET> > |
int Bloomberg::quantum::ICoroContext< RET >::closeBuffer | ( | ) |
Close a promise buffer.
BUF | Represents a class of type Buffer. |
Implemented in Bloomberg::quantum::Context< RET >.
ICoroContext< RET >::Ptr Bloomberg::quantum::ICoroContext< RET >::end | ( | ) |
This is the last method in a continuation chain.
This method effectively closes the continuation chain and posts the entire chain to be executed, respecting the 'queueId' and priority specified at the beginning of the chain (see postFirst()).
Implemented in Bloomberg::quantum::Context< RET >.
CoroContextPtr<OTHER_RET> Bloomberg::quantum::ICoroContext< RET >::finally | ( | FUNC && | func, |
ARGS &&... | args | ||
) |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
ICoroContext<OTHER_RET>::Ptr Bloomberg::quantum::ICoroContext< RET >::finally | ( | FUNC && | func, |
ARGS &&... | args | ||
) |
Posts a coroutine to run asynchronously. This coroutine is always guaranteed to run.
This function is optional for the continuation chain and may be called at most once. If called, it must immediately precede the end() method. This method will run regardless if any preceding coroutines have an error or not. It can be used for cleanup purposes, closing handles, terminating services, etc.
OTHER_RET | Type of future returned by this coroutine. |
FUNC | Callable object type which will be wrapped in a coroutine. Can be a standalone function, a method, an std::function, a functor generated via std::bind or a lambda. The signature of the callable object must strictly be 'int f(CoroContext<RET>::Ptr, ...)'. |
ARGS | Argument types passed to FUNC. |
[in] | func | Callable object. |
[in] | args | Variable list of arguments passed to the callable object. |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
CoroContextPtr<std::vector<OTHER_RET> > Bloomberg::quantum::ICoroContext< RET >::forEach | ( | INPUT_IT | first, |
INPUT_IT | last, | ||
Functions::ForEachFunc< OTHER_RET, INPUT_IT > | func | ||
) |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
CoroContextPtr<std::vector<OTHER_RET> > Bloomberg::quantum::ICoroContext< RET >::forEach | ( | INPUT_IT | first, |
size_t | num, | ||
Functions::ForEachFunc< OTHER_RET, INPUT_IT > | func | ||
) |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
ICoroContext<std::vector<OTHER_RET> >::Ptr Bloomberg::quantum::ICoroContext< RET >::forEach | ( | INPUT_IT | first, |
INPUT_IT | last, | ||
Functions::ForEachFunc< OTHER_RET, INPUT_IT > | func | ||
) |
Applies the given unary function to all the elements in the range [first,last). This function runs in parallel.
OTHER_RET | The return value of the unary function. |
UNARY_FUNC | A unary function of type 'RET(*INPUT_IT)'. |
InputIt | The type of iterator. |
[in] | first | The first element in the range. |
[in] | last | The last element in the range (exclusive). |
[in] | func | The unary function. |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
ICoroContext<std::vector<OTHER_RET> >::Ptr Bloomberg::quantum::ICoroContext< RET >::forEach | ( | INPUT_IT | first, |
size_t | num, | ||
Functions::ForEachFunc< OTHER_RET, INPUT_IT > | func | ||
) |
Applies the given unary function to all the elements in the range [first,first+num). This function runs in parallel.
OTHER_RET | The return value of the unary function. |
UNARY_FUNC | A unary function of type 'RET(*INPUT_IT)'. |
InputIt | The type of iterator. @oaram[in] first The first element in the range. @oaram[in] num The number of elements to iterate over. @oaram[in] func The unary function. |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
CoroContextPtr<std::vector<std::vector<OTHER_RET> > > Bloomberg::quantum::ICoroContext< RET >::forEachBatch | ( | INPUT_IT | first, |
INPUT_IT | last, | ||
Functions::ForEachFunc< OTHER_RET, INPUT_IT > | func | ||
) |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
CoroContextPtr<std::vector<std::vector<OTHER_RET> > > Bloomberg::quantum::ICoroContext< RET >::forEachBatch | ( | INPUT_IT | first, |
size_t | num, | ||
Functions::ForEachFunc< OTHER_RET, INPUT_IT > | func | ||
) |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
ICoroContext<std::vector<std::vector<OTHER_RET> > >::Ptr Bloomberg::quantum::ICoroContext< RET >::forEachBatch | ( | INPUT_IT | first, |
INPUT_IT | last, | ||
Functions::ForEachFunc< OTHER_RET, INPUT_IT > | func | ||
) |
Applies the given unary function to all the elements in the range [first,last). This function runs serially with respect to other functions in the same batch.
OTHER_RET | The return value of the unary function. |
UNARY_FUNC | A unary function of type 'RET(*INPUT_IT)'. |
InputIt | The type of iterator. @oaram[in] first The first element in the range. @oaram[in] last The last element in the range (exclusive). @oaram[in] func The unary function. |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
ICoroContext<std::vector<std::vector<OTHER_RET> > >::Ptr Bloomberg::quantum::ICoroContext< RET >::forEachBatch | ( | INPUT_IT | first, |
size_t | num, | ||
Functions::ForEachFunc< OTHER_RET, INPUT_IT > | func | ||
) |
Applies the given unary function to all the elements in the range [first,last). This function runs serially with respect to other functions in the same batch.
OTHER_RET | The return value of the unary function. |
UNARY_FUNC | A unary function of type 'RET(*INPUT_IT)'. |
InputIt | The type of iterator. @oaram[in] first The first element in the range. @oaram[in] last The last element in the range (exclusive). @oaram[in] func The unary function. |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
NonBufferRetType< V > Bloomberg::quantum::ICoroContext< RET >::get | ( | ICoroSync::Ptr | sync | ) |
Get the future value associated with this context.
[in] | sync | Pointer to the coroutine synchronization object. |
Implemented in Bloomberg::quantum::Context< RET >.
NonBufferRetType< OTHER_RET > Bloomberg::quantum::ICoroContext< RET >::getAt | ( | int | num, |
ICoroSync::Ptr | sync | ||
) |
Get the future value from the 'num-th' continuation context.
Allowed range for num is [-1, total_continuations). -1 is equivalent of calling get() or getAt(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.
OTHER_RET | The type of the future value associated with the 'num-th' context. |
[in] | num | The number indicating which future to wait on. |
[in] | sync | Pointer to the coroutine synchronization object. |
Implemented in Bloomberg::quantum::Context< RET >.
const std::pair< int, int > & Bloomberg::quantum::ICoroContext< RET >::getCoroQueueIdRangeForAny | ( | ) | const |
Gets the range [minQueueId, maxQueueId] of coroutine queueIds covered by IQueue::QueueId::Any by the Dispatcher.
Implemented in Bloomberg::quantum::Context< RET >.
int Bloomberg::quantum::ICoroContext< RET >::getNumCoroutineThreads | ( | ) | const |
Returns the number of underlying coroutine threads as specified in the dispatcher constructor. If -1 was passed than this number essentially indicates the number of cores.
Implemented in Bloomberg::quantum::Context< RET >.
int Bloomberg::quantum::ICoroContext< RET >::getNumIoThreads | ( | ) | const |
Returns the number of underlying IO threads as specified in the dispatcher constructor.
Implemented in Bloomberg::quantum::Context< RET >.
NonBufferRetType< OTHER_RET > Bloomberg::quantum::ICoroContext< RET >::getPrev | ( | ) |
Get the future value associated with the previous coroutine context in the continuation chain.
OTHER_RET | The type of the future value of the previous context. |
const NonBufferRetType< OTHER_RET > & Bloomberg::quantum::ICoroContext< RET >::getPrevRef | ( | ) |
Get a reference to future value associated with the previous coroutine context in the continuation chain.
OTHER_RET | The type of the future value of the previous context. |
const NonBufferRetType< V > & Bloomberg::quantum::ICoroContext< RET >::getRef | ( | ICoroSync::Ptr | sync | ) | const |
Get a reference the future value associated with this context.
[in] | sync | Pointer to the coroutine synchronization object. |
Implemented in Bloomberg::quantum::Context< RET >.
const NonBufferRetType< OTHER_RET > & Bloomberg::quantum::ICoroContext< RET >::getRefAt | ( | int | num, |
ICoroSync::Ptr | sync | ||
) | const |
Get a reference to the future value from the 'num-th' continuation context.
Allowed range for num is [-1, total_continuations). -1 is equivalent of calling get() or getAt(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.
OTHER_RET | The type of the future value associated with the 'num-th' context. |
[in] | num | The number indicating which future to wait on. |
[in] | sync | Pointer to the coroutine synchronization object. |
Implemented in Bloomberg::quantum::Context< RET >.
CoroContextPtr<std::map<KEY, REDUCED_TYPE> > Bloomberg::quantum::ICoroContext< RET >::mapReduce | ( | INPUT_IT | first, |
INPUT_IT | last, | ||
Functions::MapFunc< KEY, MAPPED_TYPE, INPUT_IT > | mapper, | ||
Functions::ReduceFunc< KEY, MAPPED_TYPE, REDUCED_TYPE > | reducer | ||
) |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
CoroContextPtr<std::map<KEY, REDUCED_TYPE> > Bloomberg::quantum::ICoroContext< RET >::mapReduce | ( | INPUT_IT | first, |
size_t | num, | ||
Functions::MapFunc< KEY, MAPPED_TYPE, INPUT_IT > | mapper, | ||
Functions::ReduceFunc< KEY, MAPPED_TYPE, REDUCED_TYPE > | reducer | ||
) |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
ICoroContext<std::map<KEY, REDUCED_TYPE> >::Ptr Bloomberg::quantum::ICoroContext< RET >::mapReduce | ( | INPUT_IT | first, |
INPUT_IT | last, | ||
Functions::MapFunc< KEY, MAPPED_TYPE, INPUT_IT > | mapper, | ||
Functions::ReduceFunc< KEY, MAPPED_TYPE, REDUCED_TYPE > | reducer | ||
) |
Implementation of map-reduce functionality.
KEY | The KEY type used for mapping and reducing. |
MAPPED_TYPE | The output type after a map operation. |
REDUCED_TYPE | The output type after a reduce operation. |
MAPPER_FUNC | The mapper function having the signature 'std::vector<std::pair<KEY,MAPPED_TYPE>>(*INPUT_IT)' |
REDUCER_FUNC | The reducer function having the signature 'std::pair<KEY,REDUCED_TYPE>(std::pair<KEY, std::vector<MAPPED_TYPE>>&&)' |
INPUT_IT | The iterator type. @oaram[in] first The start iterator to a list of items to be processed in the range [first,last). @oaram[in] last The end iterator to a list of items (not inclusive). @oaram[in] mapper The mapper function. @oaram[in] reducer The reducer function. |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
ICoroContext<std::map<KEY, REDUCED_TYPE> >::Ptr Bloomberg::quantum::ICoroContext< RET >::mapReduce | ( | INPUT_IT | first, |
size_t | num, | ||
Functions::MapFunc< KEY, MAPPED_TYPE, INPUT_IT > | mapper, | ||
Functions::ReduceFunc< KEY, MAPPED_TYPE, REDUCED_TYPE > | reducer | ||
) |
Same as mapReduce() but takes a length as second argument in case INPUT_IT is not a random access iterator.
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
CoroContextPtr<std::map<KEY, REDUCED_TYPE> > Bloomberg::quantum::ICoroContext< RET >::mapReduceBatch | ( | INPUT_IT | first, |
INPUT_IT | last, | ||
Functions::MapFunc< KEY, MAPPED_TYPE, INPUT_IT > | mapper, | ||
Functions::ReduceFunc< KEY, MAPPED_TYPE, REDUCED_TYPE > | reducer | ||
) |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
CoroContextPtr<std::map<KEY, REDUCED_TYPE> > Bloomberg::quantum::ICoroContext< RET >::mapReduceBatch | ( | INPUT_IT | first, |
size_t | num, | ||
Functions::MapFunc< KEY, MAPPED_TYPE, INPUT_IT > | mapper, | ||
Functions::ReduceFunc< KEY, MAPPED_TYPE, REDUCED_TYPE > | reducer | ||
) |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
ICoroContext<std::map<KEY, REDUCED_TYPE> >::Ptr Bloomberg::quantum::ICoroContext< RET >::mapReduceBatch | ( | INPUT_IT | first, |
INPUT_IT | last, | ||
Functions::MapFunc< KEY, MAPPED_TYPE, INPUT_IT > | mapper, | ||
Functions::ReduceFunc< KEY, MAPPED_TYPE, REDUCED_TYPE > | reducer | ||
) |
This version of mapReduce() runs both the mapper and the reducer functions in batches for improved performance. This should be used in the case where the functions are more CPU intensive with little or no IO.
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
ICoroContext<std::map<KEY, REDUCED_TYPE> >::Ptr Bloomberg::quantum::ICoroContext< RET >::mapReduceBatch | ( | INPUT_IT | first, |
size_t | num, | ||
Functions::MapFunc< KEY, MAPPED_TYPE, INPUT_IT > | mapper, | ||
Functions::ReduceFunc< KEY, MAPPED_TYPE, REDUCED_TYPE > | reducer | ||
) |
Same as mapReduceBatch() but takes a length as second argument in case INPUT_IT is not a random access iterator.
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
CoroContextPtr<OTHER_RET> Bloomberg::quantum::ICoroContext< RET >::onError | ( | FUNC && | func, |
ARGS &&... | args | ||
) |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
ICoroContext<OTHER_RET>::Ptr Bloomberg::quantum::ICoroContext< RET >::onError | ( | FUNC && | func, |
ARGS &&... | args | ||
) |
Posts a coroutine to run asynchronously. This is the error handler for a continuation chain and acts as as a 'catch' clause.
This function is optional for the continuation chain and may be called at most once. If called, it must follow postFirst() or another then() method. This method will conditionally run if-and-only-if any previous coroutines in the continuation chain return an error or throw. When a coroutine which is part of a continuation chain has an error, all subsequent then() methods are skipped and if onError() is provided it will be called. If there are no errors, this method is skipped.
OTHER_RET | Type of future returned by this coroutine. |
FUNC | Callable object type which will be wrapped in a coroutine. Can be a standalone function, a method, an std::function, a functor generated via std::bind or a lambda. The signature of the callable object must strictly be 'int f(CoroContext<RET>::Ptr, ...)'. |
ARGS | Argument types passed to FUNC. |
[in] | func | Callable object. |
[in] | args | Variable list of arguments passed to the callable object. |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
ICoroContext<OTHER_RET>::Ptr Bloomberg::quantum::ICoroContext< RET >::post | ( | FUNC && | func, |
ARGS &&... | args | ||
) |
Post a coroutine to run asynchronously.
This method will post the coroutine on any thread available. Typically it will pick one which has the smallest number of concurrent coroutines executing at the time of the post.
OTHER_RET | Type of future returned by this coroutine. |
FUNC | Callable object type which will be wrapped in a coroutine. Can be a standalone function, a method, an std::function, a functor generated via std::bind or a lambda. The signature of the callable object must strictly be 'int f(CoroContext<RET>::Ptr, ...)'. |
ARGS | Argument types passed to FUNC. |
[in] | func | Callable object. |
[in] | args | Variable list of arguments passed to the callable object. |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
ICoroContext<OTHER_RET>::Ptr Bloomberg::quantum::ICoroContext< RET >::post | ( | int | queueId, |
bool | isHighPriority, | ||
FUNC && | func, | ||
ARGS &&... | args | ||
) |
Post a coroutine to run asynchronously.
This method will post the coroutine on the specified queue (thread) with high or low priority.
OTHER_RET | Type of future returned by this coroutine. |
FUNC | Callable object type which will be wrapped in a coroutine. Can be a standalone function, a method, an std::function, a functor generated via std::bind or a lambda. The signature of the callable object must strictly be 'int f(CoroContext<RET>::Ptr, ...)'. |
ARGS | Argument types passed to FUNC. |
[in] | queueId | Id of the queue where this coroutine should run. Note that the user can specify IQueue::QueueId::Any as a value, which is equivalent to running the simpler version of post() above. Valid range is [0, numCoroutineThreads), IQueue::QueueId::Any or IQueue::QueueId::Same. When using IQueue::QueueId::Same as input, the current queueId of this execution context will be preserved for the posted coroutine thus enabling to write lock-free code. |
[in] | isHighPriority | If set to true, the coroutine will be scheduled to run immediately after the currently executing coroutine on 'queueId' has completed or has yielded. |
[in] | func | Callable object. |
[in] | args | Variable list of arguments passed to the callable object. |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
CoroContextPtr<OTHER_RET> Bloomberg::quantum::ICoroContext< RET >::post | ( | FUNC && | func, |
ARGS &&... | args | ||
) |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
CoroContextPtr<OTHER_RET> Bloomberg::quantum::ICoroContext< RET >::post | ( | int | queueId, |
bool | isHighPriority, | ||
FUNC && | func, | ||
ARGS &&... | args | ||
) |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
CoroFuturePtr< OTHER_RET > Bloomberg::quantum::ICoroContext< RET >::postAsyncIo | ( | FUNC && | func, |
ARGS &&... | args | ||
) |
Posts an IO method to run asynchronously on the IO thread pool.
OTHER_RET | Type of future returned by this function. |
FUNC | Callable object type. Can be a standalone function, a method, an std::function, a functor generated via std::bind or a lambda. The signature of the callable object must strictly be 'int f(ThreadPromise<RET>::Ptr, ...)'. |
ARGS | Argument types passed to FUNC. |
[in] | func | Callable object. |
[in] | args | Variable list of arguments passed to the callable object. |
Implemented in Bloomberg::quantum::Context< RET >.
CoroFuturePtr< OTHER_RET > Bloomberg::quantum::ICoroContext< RET >::postAsyncIo | ( | int | queueId, |
bool | isHighPriority, | ||
FUNC && | func, | ||
ARGS &&... | args | ||
) |
Posts an IO function to run asynchronously on the IO thread pool.
This method will post the function on the specified queue (thread) with high or low priority.
OTHER_RET | Type of future returned by this function. |
FUNC | Callable object type. Can be a standalone function, a method, an std::function, a functor generated via std::bind or a lambda. The signature of the callable object must strictly be 'int f(ThreadPromise<RET>::Ptr, ...)'. |
ARGS | Argument types passed to FUNC. |
[in] | queueId | Id of the queue where this function should run. Note that the user can specify IQueue::QueueId::Any as a value, which is equivalent to running the simpler version of postAsyncIo() above. Valid range is [0, numIoThreads) or IQueue::QueueId::Any. IQueue::QueueId::Same is disallowed. |
[in] | isHighPriority | If set to true, the function will be scheduled to run immediately after the currently executing function on 'queueId' has completed. |
[in] | func | Callable object. |
[in] | args | Variable list of arguments passed to the callable object. |
Implemented in Bloomberg::quantum::Context< RET >.
ICoroContext<OTHER_RET>::Ptr Bloomberg::quantum::ICoroContext< RET >::postFirst | ( | FUNC && | func, |
ARGS &&... | args | ||
) |
Posts a coroutine to run asynchronously.
This function is the head of a coroutine continuation chain and must be called only once in the chain.
OTHER_RET | Type of future returned by this coroutine. |
FUNC | Callable object type which will be wrapped in a coroutine. Can be a standalone function, a method, an std::function, a functor generated via std::bind or a lambda. The signature of the callable object must strictly be 'int f(CoroContext<RET>::Ptr, ...)'. |
ARGS | Argument types passed to FUNC. |
[in] | func | Callable object. |
[in] | args | Variable list of arguments passed to the callable object. |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
ICoroContext<OTHER_RET>::Ptr Bloomberg::quantum::ICoroContext< RET >::postFirst | ( | int | queueId, |
bool | isHighPriority, | ||
FUNC && | func, | ||
ARGS &&... | args | ||
) |
Posts a coroutine to run asynchronously.
This function is the head of a coroutine continuation chain and must be called only once in the chain.
OTHER_RET | Type of future returned by this coroutine. |
FUNC | Callable object type which will be wrapped in a coroutine. Can be a standalone function, a method, an std::function, a functor generated via std::bind or a lambda. The signature of the callable object must strictly be 'int f(CoroContext<RET>::Ptr, ...)'. |
ARGS | Argument types passed to FUNC. |
[in] | queueId | Id of the queue where this coroutine should run. Note that the user can specify IQueue::QueueId::Any as a value, which is equivalent to running the simpler version of post() above. Valid range is [0, numCoroutineThreads), IQueue::QueueId::Any or IQueue::QueueId::Same. When using IQueue::QueueId::Same as input, the current queueId of this execution context will be preserved for the posted coroutine thus enabling to write lock-free code. |
[in] | isHighPriority | If set to true, the coroutine will be scheduled to run immediately after the currently executing coroutine on 'queueId' has completed or has yielded. |
[in] | func | Callable object. |
[in] | args | Variable list of arguments passed to the callable object. |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
CoroContextPtr<OTHER_RET> Bloomberg::quantum::ICoroContext< RET >::postFirst | ( | FUNC && | func, |
ARGS &&... | args | ||
) |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
CoroContextPtr<OTHER_RET> Bloomberg::quantum::ICoroContext< RET >::postFirst | ( | int | queueId, |
bool | isHighPriority, | ||
FUNC && | func, | ||
ARGS &&... | args | ||
) |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
BufferRetType< V > Bloomberg::quantum::ICoroContext< RET >::pull | ( | ICoroSync::Ptr | sync, |
bool & | isBufferClosed | ||
) |
Pull a single value from the future buffer.
[in] | sync | Pointer to the coroutine synchronization object. |
[out] | isBufferClosed | Indicates if this buffer is closed and no more Pull operations are allowed on it. |
Implemented in Bloomberg::quantum::Context< RET >.
void Bloomberg::quantum::ICoroContext< RET >::push | ( | V && | value | ) |
Push a single value into the promise buffer.
[in] | value | Value to push at the end of the buffer. |
Implemented in Bloomberg::quantum::Context< RET >.
int Bloomberg::quantum::ICoroContext< RET >::set | ( | V && | value | ) |
Set the promised value associated with this context.
V | Type of the promised value. This should be implicitly deduced by the compiler and should always == RET. |
[in] | value | A reference to the value (l-value or r-value). |
Implemented in Bloomberg::quantum::Context< RET >.
CoroContextPtr<OTHER_RET> Bloomberg::quantum::ICoroContext< RET >::then | ( | FUNC && | func, |
ARGS &&... | args | ||
) |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.
ICoroContext<OTHER_RET>::Ptr Bloomberg::quantum::ICoroContext< RET >::then | ( | FUNC && | func, |
ARGS &&... | args | ||
) |
Posts a coroutine to run asynchronously.
This function is optional for the continuation chain and may be called 0 or more times. If called, it must follow postFirst() or another then() method.
OTHER_RET | Type of future returned by this coroutine. |
FUNC | Callable object type which will be wrapped in a coroutine. Can be a standalone function, a method, an std::function, a functor generated via std::bind or a lambda. The signature of the callable object must strictly be 'int f(CoroContext<RET>::Ptr, ...)'. |
ARGS | Argument types passed to FUNC. |
[in] | func | Callable object. |
[in] | args | Variable list of arguments passed to the callable object. |
Implemented in Bloomberg::quantum::Context< RET >, and Bloomberg::quantum::Context< RET >.