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");
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) );
79 template<
class,
class... >
class Container,
82 std::enable_if_t< detail::is_async_op_v<AsyncOp>, int> = 0
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,
94 std::enable_if_t< !detail::is_async_op_v<Res>, int> = 0
96 auto operator()( Container< Res, CArgs... > ops ) -> Container< Res, CArgs... > {
102 template <
typename AsyncOpRes>
108 template<
class,
class... >
class Container,
111 std::enable_if_t< detail::is_async_op_v<AsyncOp>, int> = 0
113 auto operator()( Container< std::shared_ptr< AsyncOp >, CArgs... > &&ops ) ->
zyppng::AsyncOpRef< Container<typename AsyncOp::value_type> > {
115 aOp->operator()( std::move(
ops) );
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
std::shared_ptr< AsyncOp< T > > AsyncOpRef
std::function< bool(const AsyncOpRes &) _cb)
WaitForHelperExt(std::function< bool(const AsyncOpRes &)> &&fn)
void resultReady(AsyncOpRes &&res)
Container< std::shared_ptr< AsyncOp >, CArgs... > _allOps
WaitForImpl(const WaitForImpl &other)=delete
WaitForImpl(std::function< bool(const AsyncOpRes &)> canContinue={})
std::function< bool(const AsyncOpRes &) _canContinue)
void operator()(Container< std::shared_ptr< AsyncOp >, CArgs... > &&ops)
WaitForImpl(WaitForImpl &&other)=default
typename AsyncOp::value_type AsyncOpRes
Container< AsyncOpRes > _allResults