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 T>
96 while (
head->next !=
nullptr) {
110template <
typename Ret,
typename Arg,
typename T,
typename Func, CoreType Type, AsyncType kAsync>
129 if constexpr (
IsRun(Type)) {
147 template <
bool SymmetricTransfer>
151 YACLIB_ASSERT(&caller ==
this || &caller == this->_self.caller);
156 if constexpr (
IsRun(Type)) {
160 if (this->_self.unwrapping != 0) {
165 this->_self.caller = &caller;
172 if constexpr (
IsCall(Type)) {
173 this->_executor->Submit(*
this);
181 [[
nodiscard]] InlineCore* Here(InlineCore& caller)
noexcept final {
184#if YACLIB_SYMMETRIC_TRANSFER != 0
185 [[
nodiscard]] yaclib_std::coroutine_handle<>
Next(InlineCore& caller)
noexcept final {
190 template <
bool SymmetricTransfer,
typename R>
201 template <
bool SymmetricTransfer,
bool Async = false,
typename R>
213 auto* caller = this->_self.caller;
214 this->Store(std::forward<R>(value));
228 if constexpr (!
Async) {
234 template <
bool SymmetricTransfer,
typename R>
268 template <
bool SymmetricTransfer,
typename R>
271 auto async = CallResolveVoid(std::forward<R>(value));
274 auto* core =
async.GetCore().Release();
275 if constexpr (!
IsRun(Type)) {
276 this->_self.caller->DecRef();
277 this->_self.unwrapping = 1;
279 this->_self.caller = core;
282 core->StoreCallback(*
this);
292 template <
typename R>
295 constexpr bool kRetVoid = std::is_void_v<invoke_t<Invoke, std::conditional_t<kArgVoid, void, R>>>;
300 std::forward<Invoke>(this->
_func.
storage)(std::forward<R>(value));
306 return std::forward<Invoke>(this->
_func.
storage)(std::forward<R>(value));
311template <
typename V,
typename T,
typename Func>
329template <
typename V,
typename T,
typename Func>
334template <
typename V,
typename T,
typename Func>
339template <
typename V,
typename T,
typename Func>
344template <
typename V,
typename T,
typename Func>
349template <CoreType CoreT,
typename Arg,
typename T,
typename Func>
351 static_assert(!
IsRun(
CoreT) || std::is_void_v<Arg>,
"It makes no sense to receive some value in first pipeline step");
354 "It makes no sense to return some value in Detach, since no one will be able to use it");
356 using Ret = std::conditional_t<std::is_same_v<Ret0, Unit>,
void,
Ret0>;
375template <CoreType CoreT,
bool On,
typename FromCorePtr,
typename Func>
380 static constexpr bool Unique = std::is_same_v<UniqueCorePtr<Arg, Trait>&,
FromCorePtr>;
381 static constexpr bool Shared = std::is_same_v<const SharedCorePtr<Arg, Trait>&,
FromCorePtr>;
395 return core.Release();
405 using ResultCoreT =
typename std::remove_reference_t<
decltype(*callback)>::Base;
407 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.
Encapsulated return value from caller.
Provides a mechanism to schedule the some async operations TODO(MBkkt) add description.
void StoreCallbackImpl(InlineCore &callback) noexcept
ResultCoreT< Type, Ret, T > Base
typename T::template Result< Arg > ResultArg
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
Transfer< SymmetricTransfer > SetResult() noexcept
void Store(R &&) 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)
std::conditional_t< IsDetach(Type), NoResultCore, std::conditional_t< IsToShared(Type), SharedCore< V, T >, UniqueCore< V, T > > > ResultCoreT
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 bool IsDetach(CoreType type)
constexpr bool IsLazy(CoreType type)
constexpr bool IsFromShared(CoreType type)
YACLIB_INLINE void Loop(InlineCore *prev, InlineCore *curr) noexcept
constexpr std::size_t kSharedRefWithFuture
constexpr bool IsRun(CoreType type)
auto * MakeCore(Func &&f)
constexpr CoreType operator&(CoreType a, CoreType b)
Contract< V, T > MakeContract()
Creates related future and promise.
YACLIB_INLINE detail::OnAwaiter On(IExecutor &e) noexcept
TODO(mkornaukhov03) Add doxygen docs.
std::remove_cv_t< std::remove_reference_t< T > > remove_cvref_t
typename detail::Invoke< Func, Arg... >::Type invoke_t
invoke_t< Func, typename T::template Result< V > > Type
invoke_t< Func, typename T::Error > Type
invoke_t< Func, Unit > Type
YACLIB_NO_UNIQUE_ADDRESS Storage storage