7 #include <execution/Executor.h> 
   28                     static_assert( std::is_invocable<F,TArg>::value, 
"NaiveExecutor::next bad functor signature");
 
   29                     if constexpr (std::is_same<std::invoke_result_t<F,TArg>,
void>::value )
 
   31                         if constexpr (std::is_nothrow_invocable<F,TArg>::value)
 
   33                             f(std::forward<TArg>(arg));
 
   40                                 f(std::forward<TArg>(arg));
 
   44                                 output.setError(std::current_exception());
 
   49                         if constexpr (std::is_nothrow_invocable<F,TArg>::value)
 
   50                             output.setValue(f(std::forward<TArg>(arg)));
 
   55                                 output.setValue(f(std::forward<TArg>(arg)));
 
   58                                 output.setError(std::current_exception());
 
   65                     if constexpr (std::is_same<std::invoke_result_t<F>,
void>::value )
 
   67                         if constexpr (std::is_nothrow_invocable<F>::value)
 
   80                                 output.setError(std::current_exception());
 
   85                         if constexpr (std::is_nothrow_invocable<F>::value)
 
   94                                 output.setError(std::current_exception());
 
  101                 template <
class ReturnTuple,
class TArg,
class ...FTypes> 
::mel::parallelism::Barrier parallel_convert(ExFuture<NaiveInlineExecutionAgent,TArg> fut,std::exception_ptr& excpt,ReturnTuple& result, FTypes&&... functions);
 
  104         namespace _naive{
namespace _private
 
  106             template <
class F,
class TArg> 
void _invokeInline(ExFuture<NaiveInlineExecutionAgent,TArg> fut,std::exception_ptr& except,F&& f)
 
  108                 static_assert( std::is_invocable<F,TArg>::value, 
"_invokeInline bad functor signature");
 
  109                 if constexpr (std::is_nothrow_invocable<F,TArg>::value)
 
  111                     f(fut.getValue().value());                    
 
  116                         f(fut.getValue().value());
 
  120                             except = std::current_exception();
 
  125             template <
class F> 
void _invokeInline(ExFuture<NaiveInlineExecutionAgent,void> fut,std::exception_ptr& except,F&& f)
 
  127                 if constexpr (std::is_nothrow_invocable<F>::value)
 
  138                             except = std::current_exception();
 
  142             template <
class TArg,
class F,
class ...FTypes> 
void _invokeInline(ExFuture<NaiveInlineExecutionAgent,TArg> fut,std::exception_ptr& except,F&& f, FTypes&&... fs)
 
  144                 _naive::_private::_invokeInline(fut,except,std::forward<F>(f));
 
  145                 _naive::_private::_invokeInline(fut,except,std::forward<FTypes>(fs)...);
 
  147             template <
int n,
class ResultTuple, 
class F,
class TArg> 
void _invokeInline_with_result(ExFuture<NaiveInlineExecutionAgent,TArg> fut,std::exception_ptr& except,ResultTuple& output,F&& f)
 
  149                 static_assert( std::is_invocable<F,TArg>::value, 
"_invokeInline_with_result bad functor signature");
 
  150                 if constexpr (std::is_nothrow_invocable<F,TArg>::value)
 
  152                     if constexpr (std::is_same< std::invoke_result_t<F,TArg>,
void >::value)
 
  153                         f(fut.getValue().value());
 
  155                         std::get<n>(output) = f(fut.getValue().value());
 
  160                         if constexpr (std::is_same< std::invoke_result_t<F,TArg>,
void >::value)
 
  161                             f(fut.getValue().value());
 
  163                             std::get<n>(output) = f(fut.getValue().value());
 
  167                             except = std::current_exception();
 
  173             template <
int n,
class ResultTuple,
class F> 
void _invokeInline_with_result(ExFuture<NaiveInlineExecutionAgent,void>& fut,std::exception_ptr& except,ResultTuple& output, F&& f)
 
  175                 if constexpr (std::is_nothrow_invocable<F>::value)
 
  177                     if constexpr (std::is_same< std::invoke_result_t<F>,
void >::value)
 
  180                         std::get<n>(output) = f();                    
 
  185                         if constexpr (std::is_same< std::invoke_result_t<F>,
void >::value)
 
  188                             std::get<n>(output) = f();
 
  192                             except = std::current_exception();
 
  197             template <
int n,
class ResultTuple,
class TArg,
class F,
class ...FTypes> 
void _invokeInline_with_result(ExFuture<NaiveInlineExecutionAgent,TArg> fut,std::exception_ptr& except,ResultTuple& output,F&& f, FTypes&&... fs)
 
  199                 _naive::_private::_invokeInline_with_result<n>(fut,except,output,std::forward<F>(f));
 
  200                 _naive::_private::_invokeInline_with_result<n+1>(fut,except,output,std::forward<FTypes>(fs)...);
 
  218             for(
auto i = begin; i != end;i+=increment)
 
  222             return ::mel::parallelism::Barrier((
size_t)0);
 
  226             _naive::_private::_invokeInline(fut,except,std::forward<FTypes>(functions)...);
 
  227             return ::mel::parallelism::Barrier((
size_t)0);
 
  229         template <
class ReturnTuple,
class TArg,
class ...FTypes> 
::mel::parallelism::Barrier Executor<NaiveInlineExecutionAgent>::parallel_convert(ExFuture<NaiveInlineExecutionAgent,TArg> fut,std::exception_ptr& except,ReturnTuple& result, FTypes&&... functions)
 
  231             _naive::_private::_invokeInline_with_result<0>(fut,except,result,std::forward<FTypes>(functions)...);
 
  232             return ::mel::parallelism::Barrier((
size_t)0);
 
Typical Traits for types.
 
Extension of mel::core::Future to apply to executors.
Definition: ExFuture.h:21
 
Executor specialization using NaiveInlineExecutionAgent as execution agent.
Definition: NaiveInlineExecutor.h:22
 
void launch(F &&f, TArg &&arg, ExFuture< NaiveInlineExecutionAgent, TRet > output) const noexcept
Definition: NaiveInlineExecutor.h:26
 
Definition: Executor.h:26
 
Multithread barrier.
Definition: Barrier.h:43
 
ExFuture< ExecutorAgent, std::invoke_result_t< F > > launch(Executor< ExecutorAgent > ex, F &&f)
Launch given functor in given executor.
Definition: Executor.h:65
 
Executor< NaiveInlineExecutionAgent > NaiveInlineExecutor
alias for Executor<NaiveInlineExecutionAgent>
Definition: NaiveInlineExecutor.h:242
 
ExFuture< ExecutorAgent, TArg > parallel(ExFuture< ExecutorAgent, TArg > source, FTypes... functions)
Execute given functions in a (possibly, depending on concrete executor) parallel way If an exception ...
Definition: Executor.h:499
 
ExFuture< ExecutorAgent, TArg > loop(ExFuture< ExecutorAgent, TArg > source, I getIteratorsFunc, F functor, int increment=1)
parallel (possibly, depending on executor capabilities) loop
Definition: Executor.h:290
 
ExFuture< ExecutorAgent, typename ::mel::execution::_private::GetReturn< TArg, FTypes... >::type > parallel_convert(ExFuture< ExecutorAgent, TArg > source, FTypes... functions)
Same as parallel but returning a tuple with the values for each functor.
Definition: Executor.h:726
 
Definition: Callback_Impl.h:11
 
Default traits for any executor.
Definition: Executor.h:46
 
Definition: NaiveInlineExecutor.h:15