8 #include <execution/Executor.h> 
    9 #include <preprocessor/utils.h> 
   22 #define CONDITION_SELECT_JOB( idx )                                            \ 
   23     if constexpr ( tsize > idx )                                               \ 
   25         using FlowType = std::tuple_element_t<idx, TupleType>;                 \ 
   27             std::is_invocable<FlowType, ExFuture<ExecutorAgent, TArg>>::value, \ 
   28             "execution::condition bad functor signature" );                    \
 
   29         launch( source.agent,                                                  \
 
   30                 [source, result, fls = std::move( fls )]() mutable noexcept    \
 
   32                     if constexpr ( std::is_nothrow_invocable<                  \
 
   34                                        ExFuture<ExecutorAgent, TArg>>::value ) \
 
   35                         result.assign( std::get<idx>( fls )( source ) );       \
 
   40                             result.assign( std::get<idx>( fls )( source ) );   \
 
   44                             result.setError( std::current_exception() );       \
 
   51         launch( source.agent,                                                  \
 
   52                 [result]() mutable noexcept                                    \
 
   54                     result.setError( std::out_of_range(                        \
 
   55                         "execution::condition. Index '" TOSTRING(              \
 
   56                             idx ) "' is greater than maximum case "            \
 
   57                                   "index " TOSTRING( tsize ) ) );              \
 
   69             template <
class ExecutorAgent, 
class TArg, 
class F, 
class... Flows>
 
   76                 typedef typename ::mel::execution::_private::GetReturn<
 
   78                 using ResultType = std::tuple_element_t<0, ResultTuple>;
 
   79                 ResultType result( source.
agent );
 
   84                     [source, selector = std::move( selector ),
 
   85                      fls = std::make_tuple( std::move( flows )... ), result](
 
   87                             input ) 
mutable noexcept( std::
 
   93                         if ( input.isValid() )
 
   95                             using TupleType = decltype( fls );
 
   97                             size_t idx = selector( input.value() );
 
   98                             constexpr size_t tsize =
 
   99                                 std::tuple_size<TupleType>::value;
 
  133                                 CONDITION_SELECT_JOB( 0 )
 
  136                                 CONDITION_SELECT_JOB( 1 )
 
  139                                 CONDITION_SELECT_JOB( 2 )
 
  142                                 CONDITION_SELECT_JOB( 3 )
 
  145                                 CONDITION_SELECT_JOB( 4 )
 
  148                                 CONDITION_SELECT_JOB( 5 )
 
  151                                 CONDITION_SELECT_JOB( 6 )
 
  154                                 CONDITION_SELECT_JOB( 7 )
 
  157                                 CONDITION_SELECT_JOB( 8 )
 
  160                                 CONDITION_SELECT_JOB( 9 )
 
  167                             std::exception_ptr err = input.error();
 
  169                                     [result, err]() 
mutable noexcept
 
  170                                     { result.setError( std::move( err ) ); } );
 
  180                     template <
class S, 
class... Fs>
 
  182                         : mSelector( std::forward<F>( selector ) ),
 
  183                           mFuncs( std::forward<Fs>( fs )... )
 
  187                     std::tuple<FTypes...> mFuncs;
 
  188                     template <
class TArg, 
class ExecutorAgent>
 
  192                                           std::forward<F>( mSelector ),
 
  193                                           std::forward<FTypes>(
 
  194                                               std::get<FTypes>( mFuncs ) )... );
 
  200             template <
class F, 
class... FTypes>
 
  205                     std::forward<F>( selector ),
 
  206                     std::forward<FTypes>( functions )... );
 
int subscribeCallback(F &&f) const
Subscribe callback to be executed when future is ready (valid or error)
Definition: Future.h:681
 
Executor< ExecutorAgent > agent
execution agent associated with this instance
Definition: ExFuture.h:54
 
FlowsResult< typename ::mel::execution::_private::GetReturn< ExFuture< ExecutorAgent, TArg >, Flows... >::type > launch(ExFuture< ExecutorAgent, TArg > source, Flows... flows)
Launch given set of flows.
Definition: Launch.h:85
 
auto condition(ExFuture< ExecutorAgent, TArg > source, F selector, Flows... flows)
Select functor to execute.
Definition: Condition.h:70
 
Definition: Callback_Impl.h:11
 
Definition: Condition.h:179