7#include <yaclib/config.hpp>
30 template <
bool SymmetricTransfer>
32 return BaseCore::SetResultImpl<SymmetricTransfer, false>();
51 return static_cast<CoreType>(
static_cast<unsigned char>(
a) |
static_cast<unsigned char>(
b));
55 return static_cast<CoreType>(
static_cast<unsigned char>(
a) &
static_cast<unsigned char>(
b));
90template <CoreType Type,
typename V,
typename E>
96 while (
head->next !=
nullptr) {
110template <
typename Ret,
typename Arg,
typename E,
typename Func, CoreType Type, AsyncType kAsync>
128 if constexpr (
IsRun(Type)) {
146 template <
bool SymmetricTransfer>
150 YACLIB_ASSERT(&caller ==
this || &caller == this->_self.caller);
155 if constexpr (
IsRun(Type)) {
159 if (this->_self.unwrapping != 0) {
164 this->_self.caller = &caller;
171 if constexpr (
IsCall(Type)) {
172 this->_executor->Submit(*
this);
180 [[
nodiscard]] InlineCore* Here(InlineCore& caller)
noexcept final {
183#if YACLIB_SYMMETRIC_TRANSFER != 0
184 [[
nodiscard]] yaclib_std::coroutine_handle<>
Next(InlineCore& caller)
noexcept final {
189 template <
bool SymmetricTransfer,
typename T>
200 template <
bool SymmetricTransfer,
bool Async = false,
typename T>
212 auto* caller = this->_self.caller;
213 this->Store(std::forward<T>(
value));
227 if constexpr (!
Async) {
233 template <
bool SymmetricTransfer,
typename Result>
235 const auto state =
r.State();
264 static_assert(
kIsException ^
kIsError,
"Recovery callback should be invokable with std::exception_ptr or E");
267 using T = std::conditional_t<kIsException, std::exception_ptr, E>;
274 template <
bool SymmetricTransfer,
typename T>
277 auto async = CallResolveVoid(std::forward<T>(
value));
280 auto* core =
async.GetCore().Release();
281 if constexpr (!
IsRun(Type)) {
282 this->_self.caller->DecRef();
283 this->_self.unwrapping = 1;
285 this->_self.caller = core;
288 core->StoreCallback(*
this);
298 template <
typename T>
301 constexpr bool kRetVoid = std::is_void_v<invoke_t<Invoke, std::conditional_t<kArgVoid, void, T>>>;
317template <
typename V,
typename E,
typename Func>
337template <
typename V,
typename E,
typename Func>
342template <
typename V,
typename E,
typename Func>
347template <
typename V,
typename E,
typename Func>
352template <
typename V,
typename E,
typename Func>
357template <
typename V,
typename E,
typename Func>
362template <CoreType CoreT,
typename Arg,
typename E,
typename Func>
364 static_assert(!
IsRun(
CoreT) || std::is_void_v<Arg>,
"It makes no sense to receive some value in first pipeline step");
367 "It makes no sense to return some value in Detach, since no one will be able to use it");
369 using Ret = std::conditional_t<std::is_same_v<Ret0, Unit>,
void,
Ret0>;
388template <CoreType CoreT,
bool On,
typename FromCorePtr,
typename Func>
393 static constexpr bool Unique = std::is_same_v<UniqueCorePtr<Arg, E>&,
FromCorePtr>;
394 static constexpr bool Shared = std::is_same_v<const SharedCorePtr<Arg, E>&,
FromCorePtr>;
408 return core.Release();
418 using ResultCoreT =
typename std::remove_reference_t<
decltype(*callback)>::Base;
420 static_assert(!
Shared,
"Shared + Lazy (SharedTask) is not supported");
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 StoreCallbackImpl(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
Transfer< SymmetricTransfer > SetResult() noexcept
void StoreCallback(InlineCore &callback) noexcept
#define YACLIB_ASSERT(cond)
constexpr CoreType operator|(CoreType a, CoreType b)
constexpr char Tag() noexcept
constexpr bool IsFromUnique(CoreType type)
constexpr bool IsToUnique(CoreType type)
auto SetCallback(FromCorePtr &&core, IExecutor *executor, Func &&f)
constexpr bool IsToShared(CoreType type)
YACLIB_INLINE BaseCore * MoveToCaller(BaseCore *head) noexcept
constexpr bool IsCall(CoreType type)
InlineCore & MakeDrop() noexcept
constexpr size_t kSharedRefWithFuture
constexpr bool IsDetach(CoreType type)
constexpr bool IsLazy(CoreType type)
std::conditional_t< IsDetach(Type), NoResultCore, std::conditional_t< IsToShared(Type), SharedCore< V, E >, UniqueCore< V, E > > > ResultCoreT
constexpr bool IsFromShared(CoreType type)
YACLIB_INLINE void Loop(InlineCore *prev, InlineCore *curr) noexcept
constexpr bool IsRun(CoreType type)
auto * MakeCore(Func &&f)
constexpr CoreType operator&(CoreType a, CoreType b)
YACLIB_INLINE detail::OnAwaiter On(IExecutor &e) noexcept
TODO(mkornaukhov03) Add doxygen docs.
Contract< V, E > MakeContract()
Creates related future and promise.
std::remove_cv_t< std::remove_reference_t< T > > remove_cvref_t
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