5#include <yaclib/config.hpp>
33template <CoreType Type,
typename V,
typename E>
34using ResultCoreT = std::conditional_t<Type == CoreType::Detach, NoResultCore, ResultCore<V, E>>;
38 while (
head->next !=
nullptr) {
46template <
typename Ret,
typename Arg,
typename E,
typename Func, CoreType Type,
bool kIsAsync,
bool kIsCall>
82 template <
bool SymmetricTransfer>
85 YACLIB_ASSERT(&caller ==
this || &caller == this->_self.caller);
93 if (this->_self.unwrapping != 0) {
98 this->_self.caller = &caller;
101 this->_executor->Submit(*
this);
109 [[
nodiscard]] InlineCore* Here(InlineCore& caller)
noexcept final {
112#if YACLIB_SYMMETRIC_TRANSFER != 0
113 [[
nodiscard]] yaclib_std::coroutine_handle<>
Next(InlineCore& caller)
noexcept final {
118 template <
bool SymmetricTransfer,
typename T>
129 template <
bool SymmetricTransfer,
bool Async = false,
typename T>
141 auto* caller = this->_self.caller;
142 this->Store(std::forward<T>(
value));
146 if constexpr (!
Async) {
152 template <
bool SymmetricTransfer>
154 const auto state =
r.State();
183 static_assert(
kIsException ^
kIsError,
"Recovery callback should be invokable with std::exception_ptr or E");
186 using T = std::conditional_t<kIsException, std::exception_ptr, E>;
193 template <
bool SymmetricTransfer,
typename T>
196 auto async = CallResolveVoid(std::forward<T>(
value));
197 BaseCore*
core =
async.GetCore().Release();
199 this->_self.caller->DecRef();
200 this->_self.unwrapping = 1;
202 this->_self.caller =
core;
205 core->StoreCallback(*
this);
216 template <
typename T>
219 constexpr bool kRetVoid = std::is_void_v<invoke_t<Invoke, std::conditional_t<kArgVoid, void, T>>>;
235template <
typename V,
typename E,
typename Func>
255template <
typename V,
typename E,
typename Func>
260template <
typename V,
typename E,
typename Func>
265template <
typename V,
typename E,
typename Func>
270template <
typename V,
typename E,
typename Func>
275template <
typename V,
typename E,
typename Func>
280template <CoreType CoreT,
bool kIsCall,
typename Arg,
typename E,
typename Func>
283 "It makes no sense to receive some value in first pipeline step");
286 "It makes no sense to return some value in Detach, since no one will be able to use it");
288 using Ret = std::conditional_t<std::is_same_v<Ret0, Unit>,
void,
Ret0>;
303template <CoreType CoreT, CallbackType CallbackT,
typename Arg,
typename E,
typename Func>
319 using ResultCoreT =
typename std::remove_reference_t<
decltype(*callback)>::Base;
Provides a mechanism to access the result of async operations.
Provides a mechanism to access the result of async operations.
A intrusive pointer to objects with an embedded reference count.
Provides a mechanism to schedule the some async operations TODO(MBkkt) add description.
void StoreCallback(InlineCore &callback) noexcept
Transfer< SymmetricTransfer > SetInline(InlineCore &callback) noexcept
ResultCoreT< Type, Ret, E > Base
std::decay_t< Func > Storage
YACLIB_NO_UNIQUE_ADDRESS State _func
std::conditional_t< std::is_function_v< std::remove_reference_t< Func > >, Storage, Func > Invoke
void Store(T &&) noexcept
#define YACLIB_ASSERT(cond)
auto SetCallback(ResultCorePtr< Arg, E > &core, IExecutor *executor, Func &&f)
constexpr char Tag() noexcept
auto * MakeCore(Func &&f)
YACLIB_INLINE BaseCore * MoveToCaller(BaseCore *head) noexcept
InlineCore & MakeDrop() noexcept
YACLIB_INLINE void Loop(InlineCore *prev, InlineCore *curr) noexcept
Contract< V, E > MakeContract()
Creates related future and promise.
typename detail::Invoke< Func, Arg... >::Type invoke_t
typename detail::InstantiationTypes< Result, T >::Value result_value_t
invoke_t< Func, Result< V, E > > Type
invoke_t< Func, std::exception_ptr > Type
invoke_t< Func, Unit > Type
YACLIB_NO_UNIQUE_ADDRESS Storage storage