14#ifndef ZYPPNG_ASYNC_ASYNCOP_H_INCLUDED
15#define ZYPPNG_ASYNC_ASYNCOP_H_INCLUDED
18#include <zypp-core/zyppng/base/Base>
20#include <zypp-core/zyppng/base/Signals>
26 template <
typename Result>
struct AsyncOp;
30 template <
typename T,
typename Enable = std::
void_t<> >
39 template <
typename T,
typename Enable =
void >
43 struct is_asyncop_type<T,
std::enable_if_t< std::is_convertible_v<T*, AsyncOp<typename T::value_type>*> >> :
public std::true_type{};
60 template <
typename T>
72 :
Exception(
"AsyncOp instance not ready" )
82 :
Exception (
"AsyncOp does not support cancelling the operation")
160 template <
typename Result>
166 using Ptr = std::shared_ptr<AsyncOp<Result>>;
186 auto weak = weak_from_this();
188 if ( !weak.expired() )
217 template<
typename Fun >
219 this->
_readyCb = std::forward<Fun>(cb);
223 auto weak = weak_from_this();
227 if ( !weak.expired() ) {
254 template <
typename T>
265 template <
typename Base,
typename Result =
typename Base::value_type>
268 template <
typename ...Args>
273 static_cast<Base *
>(
this)->setReady( std::forward<
decltype(val)>(val) );
283 template <
typename T>
296 template <
typename T,
bool isAsync = true>
298 if constexpr ( isAsync ) {
299 return std::make_shared<detail::ReadyResult<T>>( std::forward<T>(result) );
Base class for Exception.
SignalProxy< void()> sigStarted()
Signal< void()> _sigReady
Signal< void(const std::string &, int, int)> _sigProgress
SignalProxy< void(const std::string &, int, int)> sigProgress()
SignalProxy< void()> sigReady()
Signal< void()> _sigStarted
AsyncOpNotReadyException()
~AsyncOpNotReadyException() override
CancelNotImplementedException()
~CancelNotImplementedException() override
typename conditional< B, T, F >::type conditional_t
constexpr bool is_async_op_v
std::conjunction< has_value_type< remove_smart_ptr_t< T > >, is_asyncop_type< remove_smart_ptr_t< T > > > is_async_op
constexpr bool has_value_type_v
constexpr bool is_asyncop_type_v
std::conditional_t< isAsync, AsyncOpRef< T >, T > makeReadyResult(T &&result)
std::shared_ptr< AsyncOp< T > > AsyncOpRef
AsyncOp(AsyncOp &&other) noexcept=default
std::optional< value_type > _maybeValue
void setReady(value_type &&val)
AsyncOp & operator=(const AsyncOp &other)=delete
std::function< void(value_type &&)> _readyCb
AsyncOp(const AsyncOp &other)=delete
std::shared_ptr< AsyncOp< Result > > Ptr
void operator()(Args &&...args)
AsyncOpRef< Result > _nestedPipeline
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
#define ZYPP_FWD_DECL_TYPE_WITH_REFS(T)