16 #ifndef BLOOMBERG_QUANTUM_ICORO_CONTEXT_H 17 #define BLOOMBERG_QUANTUM_ICORO_CONTEXT_H 19 #include <quantum/quantum_functions.h> 20 #include <quantum/interface/quantum_icoro_context_base.h> 21 #include <quantum/interface/quantum_icoro_future.h> 41 using Ptr = std::shared_ptr<ICoroContext<RET>>;
49 template <
class V = RET>
57 template <
class V = RET>
66 template <
class OTHER_RET>
74 template <
class OTHER_RET>
87 template <
class OTHER_RET>
100 template <
class OTHER_RET>
108 template <
class V,
class = NonBufferType<RET,V>>
117 template <
class V,
class = BufferType<RET,V>>
118 void push(V&& value);
127 template <
class V = RET>
135 template <
class V = RET,
class = BufferRetType<V>>
184 template <
class OTHER_RET = int,
class FUNC,
class ... ARGS>
186 post(FUNC&& func, ARGS&&... args);
207 template <
class OTHER_RET = int,
class FUNC,
class ... ARGS>
209 post(
int queueId,
bool isHighPriority, FUNC&& func, ARGS&&... args);
223 template <
class OTHER_RET = int,
class FUNC,
class ... ARGS>
246 template <
class OTHER_RET = int,
class FUNC,
class ... ARGS>
248 postFirst(
int queueId,
bool isHighPriority, FUNC&& func, ARGS&&... args);
264 template <
class OTHER_RET = int,
class FUNC,
class ... ARGS>
266 then(FUNC&& func, ARGS&&... args);
285 template <
class OTHER_RET = int,
class FUNC,
class ... ARGS>
287 onError(FUNC&& func, ARGS&&... args);
302 template <
class OTHER_RET = int,
class FUNC,
class ... ARGS>
304 finally(FUNC&& func, ARGS&&... args);
323 template <
class OTHER_RET = int,
class FUNC,
class ... ARGS>
343 template <
class OTHER_RET = int,
class FUNC,
class ... ARGS>
345 postAsyncIo(
int queueId,
bool isHighPriority, FUNC&& func, ARGS&&... args);
358 template <
class OTHER_RET =
int,
class INPUT_IT,
class = Traits::IsInputIterator<INPUT_IT>>
373 template <
class OTHER_RET =
int,
class INPUT_IT>
389 template <
class OTHER_RET =
int,
class INPUT_IT,
class = Traits::IsInputIterator<INPUT_IT>>
405 template <
class OTHER_RET =
int,
class INPUT_IT>
483 #endif //BLOOMBERG_QUANTUM_ICORO_CONTEXT_H int getNumIoThreads() const
Returns the number of underlying IO threads as specified in the dispatcher constructor.
Definition: quantum_context_impl.h:218
Definition: quantum_buffer_impl.h:22
typename ICoroFuture< T >::Ptr CoroFuturePtr
Definition: quantum_icoro_future.h:72
std::shared_ptr< IContextBase > Ptr
Definition: quantum_icontext_base.h:35
Ptr end()
This is the last method in a continuation chain.
Definition: quantum_context_impl.h:287
const NonBufferRetType< V > & getRef(ICoroSync::Ptr sync) const
Get a reference the future value associated with this context.
Definition: quantum_context_impl.h:146
ICoroContext< OTHER_RET >::Ptr postFirst(FUNC &&func, ARGS &&... args)
Posts a coroutine to run asynchronously.
Exposes methods to manipulate the coroutine context.
Definition: quantum_icoro_context.h:38
typename ICoroContext< RET >::Ptr CoroContextPtr
Definition: quantum_icoro_context.h:479
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 pe...
int getNumCoroutineThreads() const
Returns the number of underlying coroutine threads as specified in the dispatcher constructor....
Definition: quantum_context_impl.h:212
std::shared_ptr< ICoroSync > Ptr
Definition: quantum_icoro_sync.h:36
std::function< RET(const typename std::iterator_traits< INPUT_IT >::value_type &)> ForEachFunc
Definition: quantum_functions.h:34
const std::pair< int, int > & getCoroQueueIdRangeForAny() const
Gets the range [minQueueId, maxQueueId] of coroutine queueIds covered by IQueue::QueueId::Any by the ...
Definition: quantum_context_impl.h:224
CoroFuturePtr< OTHER_RET > postAsyncIo(FUNC &&func, ARGS &&... args)
Posts an IO method to run asynchronously on the IO thread pool.
Definition: quantum_context_impl.h:295
std::function< std::vector< std::pair< KEY, MAPPED_TYPE > >(const typename std::iterator_traits< INPUT_IT >::value_type &)> MapFunc
Definition: quantum_functions.h:37
std::enable_if_t<!Traits::IsBuffer< T >::value, typename Traits::IsBuffer< T >::Type > NonBufferRetType
Definition: quantum_traits.h:95
NonBufferRetType< OTHER_RET > getAt(int num, ICoroSync::Ptr sync)
Get the future value from the 'num-th' continuation context.
Definition: quantum_context_impl.h:169
Concrete class representing a coroutine or a thread context.
Definition: quantum_icoro_context.h:29
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 ...
int closeBuffer()
Close a promise buffer.
Definition: quantum_context_impl.h:206
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.
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...
NonBufferRetType< V > get(ICoroSync::Ptr sync)
Get the future value associated with this context.
Definition: quantum_context_impl.h:139
const NonBufferRetType< OTHER_RET > & getRefAt(int num, ICoroSync::Ptr sync) const
Get a reference to the future value from the 'num-th' continuation context.
Definition: quantum_context_impl.h:176
const NonBufferRetType< OTHER_RET > & getPrevRef()
Get a reference to future value associated with the previous coroutine context in the continuation ch...
Definition: quantum_context_impl.h:161
std::function< std::pair< KEY, REDUCED_TYPE >(std::pair< KEY, std::vector< MAPPED_TYPE > > &&)> ReduceFunc
Definition: quantum_functions.h:40
int set(V &&value)
Set the promised value associated with this context.
Definition: quantum_context_impl.h:183
std::shared_ptr< ICoroContext< RET > > Ptr
Definition: quantum_icoro_context.h:41
void push(V &&value)
Push a single value into the promise buffer.
Definition: quantum_context_impl.h:191
std::enable_if_t< Traits::IsBuffer< T >::value, typename Traits::IsBuffer< T >::Type > BufferRetType
Definition: quantum_traits.h:93
NonBufferRetType< OTHER_RET > getPrev()
Get the future value associated with the previous coroutine context in the continuation chain.
Definition: quantum_context_impl.h:153
std::enable_if_t< std::is_convertible< typename std::iterator_traits< IT >::iterator_category, std::input_iterator_tag >::value > IsInputIterator
Definition: quantum_traits.h:62
BufferRetType< V > pull(ICoroSync::Ptr sync, bool &isBufferClosed)
Pull a single value from the future buffer.
Definition: quantum_context_impl.h:199
ICoroContext< OTHER_RET >::Ptr post(FUNC &&func, ARGS &&... args)
Post a coroutine to run asynchronously.
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 se...
Definition: quantum_icontext_base.h:25
ICoroContext< OTHER_RET >::Ptr then(FUNC &&func, ARGS &&... args)
Posts a coroutine to run asynchronously.
Exposes methods to manipulate the coroutine context, especially future wait methods.
Definition: quantum_icoro_context_base.h:32