14 #ifndef ZYPP_ZYPPNG_MONADIC_WAIT_H 15 #define ZYPP_ZYPPNG_MONADIC_WAIT_H 17 #include <zypp-core/zyppng/pipelines/AsyncResult> 24 template <
template<
class,
class... >
class Container,
32 static_assert( detail::is_async_op_v<AsyncOp>,
"Result type needs to be derived from AsyncOp");
35 : _canContinue( std::move(canContinue) ){};
37 WaitForImpl (
const WaitForImpl &other ) =
delete;
38 WaitForImpl& operator= (
const WaitForImpl &other ) =
delete;
40 WaitForImpl& operator= ( WaitForImpl &&other ) =
default;
41 WaitForImpl ( WaitForImpl &&other ) =
default;
43 void operator()( Container< std::shared_ptr<AsyncOp>, CArgs...> &&ops ) {
44 assert( _allOps.empty() );
47 this->setReady( std::move(_allResults) );
50 _allOps = std::move( ops );
51 for (
auto &op : _allOps ) {
53 this->resultReady( std::move(res));
60 _allResults.push_back( std::move( res ) );
62 bool done = ( _allOps.size() == _allResults.size()) || ( _canContinue && !_canContinue(_allResults.back()));
67 this->setReady( std::move(_allResults) );
71 Container< std::shared_ptr<AsyncOp>, CArgs... >
_allOps;
79 template<
class,
class... >
class Container,
84 auto operator()( Container< std::shared_ptr< AsyncOp >, CArgs... > &&ops ) ->
zyppng::AsyncOpRef< Container<typename AsyncOp::value_type> > {
86 aOp->operator()( std::move(ops) );
91 template<
class,
class... >
class Container,
96 auto operator()( Container< Res, CArgs... > ops ) -> Container< Res, CArgs... > {
102 template <
typename AsyncOpRes>
108 template<
class,
class... >
class Container,
113 auto operator()( Container< std::shared_ptr< AsyncOp >, CArgs... > &&ops ) ->
zyppng::AsyncOpRef< Container<typename AsyncOp::value_type> > {
115 aOp->operator()( std::move(ops) );
120 std::function<bool( const AsyncOpRes &)>
_cb;
std::function< bool(const AsyncOpRes &)> _cb
typename enable_if< B, T >::type enable_if_t
Container< std::shared_ptr< AsyncOp >, CArgs... > _allOps
Container< AsyncOpRes > _allResults
std::function< bool(const AsyncOpRes &)> _canContinue
std::shared_ptr< AsyncOp< T > > AsyncOpRef
void resultReady(AsyncOpRes &&res)
typename AsyncOp::value_type AsyncOpRes
void operator()(Container< std::shared_ptr< AsyncOp >, CArgs... > &&ops)
WaitForHelperExt(std::function< bool(const AsyncOpRes &)> &&fn)
WaitForImpl(std::function< bool(const AsyncOpRes &)> canContinue={})