7 #include <execution/Executor.h> 
    8 #include <preprocessor/utils.h> 
   19                 template <
class Flow, 
class Predicate, 
class ExecutorAgent,
 
   20                           class TArg, 
class FlowResult>
 
   22                     : 
public std::enable_shared_from_this<WhileImpl<
 
   23                           Flow, Predicate, ExecutorAgent, TArg, FlowResult>>
 
   28                     template <
class F, 
class P>
 
   30                         Flow, Predicate, ExecutorAgent, TArg, FlowResult>>
 
   31                     create( F&& f, P&& p, 
SourceType source, FlowResult result )
 
   33                         auto ptr = 
new WhileImpl<Flow, Predicate, ExecutorAgent,
 
   35                             std::forward<F>( f ), std::forward<P>( p ), source,
 
   38                             Flow, Predicate, ExecutorAgent, TArg, FlowResult>>(
 
   45                         auto fut = mFlow( mSource );
 
   47                             WhileImpl<Flow, Predicate, ExecutorAgent, TArg,
 
   48                                       FlowResult>::shared_from_this();
 
   49                         fut.subscribeCallback( [_this, fut]( 
auto v )
 
   50                                                { _this->_callback( fut ); } );
 
   64                     template <
class F, 
class P>
 
   66                         : mFlow( std::forward<F>( f ) ),
 
   67                           mPred( std::forward<P>( p ) ), mSource( s ),
 
   71                     void _callback( FlowResult res )
 
   73                         typename FlowResult::ValueType& val = res.
getValue();
 
   76                             if constexpr ( std::is_same<
 
   77                                                typename FlowResult::ValueType::
 
   84                                     mResult.assign( res );
 
   88                                 if ( mPred( val.value() ) )
 
   91                                     mResult.assign( res );
 
   96                                 std::move( res.getValue().error() ) );
 
  114             template <
class ExecutorAgent, 
class TArg, 
class Flow,
 
  120                     std::is_invocable<Flow,
 
  122                     "execution::doWhile bad flow signature" );
 
  125                 typedef std::invoke_result_t<Flow,
 
  128                 TRet result( source.
agent );
 
  133                     [source, flow = std::move( flow ), p = std::move( p ),
 
  134                      result]( ValueType& input ) 
mutable 
  136                         if ( input.isValid() )
 
  138                             auto _while = _private::WhileImpl<
 
  139                                 Flow, Predicate, ExecutorAgent, TArg,
 
  140                                 TRet>::create( std::move( flow ),
 
  141                                                std::move( p ), source, result );
 
  148                                 [result, err = std::move(
 
  149                                              input.error() )]() mutable noexcept
 
  150                                 { result.setError( std::move( err ) ); } );
 
  159                     template <
class F, 
class P>
 
  161                         : mFlow( std::forward<F>( flow ) ),
 
  162                           mPred( std::forward<P>( p ) )
 
  171                     template <
class TArg, 
class ExecutorAgent>
 
  174                         return doWhile( inputFut, std::forward<Flow>( mFlow ),
 
  175                                         std::forward<Predicate>( mPred ) );
 
  181             template <
class Flow, 
class Predicate>
 
  186                     std::forward<Flow>( flow ),
 
  187                     std::forward<Predicate>( pred ) );
 
int subscribeCallback(F &&f) const
Subscribe callback to be executed when future is ready (valid or error)
Definition: Future.h:681
 
const _private::FutureData< T >::ValueType & getValue() const
Get the Value object.
Definition: Future.h:613
 
Executor< ExecutorAgent > agent
execution agent associated with this instance
Definition: ExFuture.h:54
 
auto doWhile(ExFuture< ExecutorAgent, TArg > source, Flow flow, Predicate p)
do...while a flow
Definition: While.h:116
 
Definition: Callback_Impl.h:11