MEL
Microthread & Execution library
mel::execution::flow Namespace Reference

Functions for flow management. More...

Classes

struct  FlowsResult
 !brief tuple wrapper for holding result of flows execution More...
 

Functions

template<class ExecutorAgent , class TArg , class F , class... Flows>
auto condition (ExFuture< ExecutorAgent, TArg > source, F selector, Flows... flows)
 Select functor to execute. More...
 
template<class F , class... FTypes>
_private::ApplyCondition< F, FTypes... > condition (F &&selector, FTypes &&... functions)
 version for use with operator |
 
template<class TArg , class ExecutorAgent , class... Flows>
FlowsResult< typename ::mel::execution::_private::GetReturn< ExFuture< ExecutorAgent, TArg >, Flows... >::type > launch (ExFuture< ExecutorAgent, TArg > source, Flows... flows)
 Launch given set of flows. More...
 
template<class ExecutionAgent , class TupleFlow >
auto on_all (Executor< ExecutionAgent > ex, TupleFlow &&f)
 Takes a tuple with the results of execution of some flows and does a execution::on_all.
 
template<class... Flows>
_private::ApplyLaunch< Flows... > launch (Flows &&... flows)
 version for use with operator |
 
template<class ExecutionAgent >
auto on_all (Executor< ExecutionAgent > ex)
 
template<class TupleType , class U >
auto operator| (const FlowsResult< TupleType > &input, U &&u)
 overload operator | for chaining a FlowsResult
 
template<class TupleType , class U >
auto operator| (FlowsResult< TupleType > &&input, U &&u)
 
template<class TArg , class ExecutorAgent , class Flow , class I >
ExFuture< ExecutorAgent, void > loop (ExFuture< ExecutorAgent, TArg > source, I getIteratorsFunc, Flow flow, int increment=1)
 Loop with independent iterations. More...
 
template<class I , class F >
flow::_private::ApplyLoop< I, F > loop (I &&getItFunc, F &&flow, int increment=1)
 version for use with operator |
 
template<class ExecutorAgent , class TArg , class Flow , class Predicate >
auto doWhile (ExFuture< ExecutorAgent, TArg > source, Flow flow, Predicate p)
 do...while a flow More...
 
template<class Flow , class Predicate >
_private::ApplyWhile< Flow, Predicate > doWhile (Flow &&flow, Predicate &&pred)
 version for use with operator |
 

Detailed Description

Functions for flow management.

Function Documentation

◆ condition()

template<class ExecutorAgent , class TArg , class F , class... Flows>
auto mel::execution::flow::condition ( ExFuture< ExecutorAgent, TArg >  source,
selector,
Flows...  flows 
)

Select functor to execute.

Callable selector return an unsigned int with is the index of de callable in jobs If index is greater than available callables, an std::out_of_range error is set

Parameters
selectorcallable with signature 'size_t f(TArg)'
flowsvariable number of callables to choose in selector

◆ doWhile()

template<class ExecutorAgent , class TArg , class Flow , class Predicate >
auto mel::execution::flow::doWhile ( ExFuture< ExecutorAgent, TArg >  source,
Flow  flow,
Predicate  p 
)

do...while a flow

implement the pseudocode: do { r = flow() }while(predicate(r)) So, it's a sequential loop, not a parallel one where each iteration is independent

Parameters
sourceinput ExFuture from previous job
flowflow to execute
ppredicate to finish loop (returing false) or to continue (returning true)
Returns
last result of the flow

◆ launch()

template<class TArg , class ExecutorAgent , class... Flows>
FlowsResult<typename ::mel::execution::_private::GetReturn< ExFuture<ExecutorAgent, TArg>, Flows...>::type> mel::execution::flow::launch ( ExFuture< ExecutorAgent, TArg >  source,
Flows...  flows 
)

Launch given set of flows.

Parameters
sourceprevious result in current job
flowscallables with the form ExFuture f(ExFuture)
Returns
a std::tuple with the ExFuture result of each flow (in order)

◆ loop()

template<class TArg , class ExecutorAgent , class Flow , class I >
ExFuture<ExecutorAgent, void> mel::execution::flow::loop ( ExFuture< ExecutorAgent, TArg >  source,
getIteratorsFunc,
Flow  flow,
int  increment = 1 
)

Loop with independent iterations.

Executes flow in a (possibly) independent way (depending on underlying executor). This flow need a first parameter being the iterator: f(I idx, auto input)

Parameters
sourceprevious result in current job
getIteratorsFuncCallable returning an std::array<I,2> with begin and end iterators to loop in
flowscallables with the form ExFuture f(ExFuture)
Returns
a std::tuple with the ExFuture result of each flow (in order)