22 template <
typename Promise>
23 YACLIB_INLINE
auto await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
24 _caller.StoreCallback(handle.promise());
26#if YACLIB_SYMMETRIC_TRANSFER != 0
27 return next->Next(handle.promise());
29 return Loop(&handle.promise(), next);
40template <
typename V,
typename E>
51 template <
typename Promise>
52 YACLIB_INLINE
auto await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
53 _result->StoreCallback(handle.promise());
55#if YACLIB_SYMMETRIC_TRANSFER != 0
56 return next->Next(handle.promise());
58 return Loop(&handle.promise(), next);
63 return std::move(_result->Get()).Ok();
70template <
typename Handle>
87template <
typename Handle,
bool Sticky>
90template <
typename Handle>
94 template <
typename Promise>
95 YACLIB_INLINE
bool await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
96 return Handle{*this->_core}.SetCallback(handle.promise());
100template <
typename Handle>
104 template <
typename Promise>
105 YACLIB_INLINE
bool await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
106 auto caller_handle = Handle{*this->_core};
107 this->_core = &handle.promise();
108 return caller_handle.SetCallback(*
this);
112 this->_core->_executor->Submit(*this->_core);
120#if YACLIB_SYMMETRIC_TRANSFER != 0
121 [[nodiscard]] yaclib_std::coroutine_handle<> Next(
InlineCore& caller)
noexcept final {
128template <
bool Sticky>
140 template <
bool SymmetricTransfer>
147 auto*
curr =
static_cast<InlineCore*
>(
next);
164#if YACLIB_SYMMETRIC_TRANSFER != 0
171template <
typename Event>
174 static constexpr auto kShared = Event::kShared;
181 template <
typename It>
187 return this->Get(std::memory_order_acquire) == 1;
190 template <
typename Promise>
192 this->next = &
handle.promise();
193 return !this->SubEqual(1);
200template <
bool Shared,
typename V,
typename E>
203template <
typename V,
typename E>
211 return !_result->Empty();
214 template <
typename Promise>
215 YACLIB_INLINE
bool await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
216 return _result->SetCallback(handle.promise());
220 return std::move(_result->Get()).Ok();
228template <
typename V,
typename E>
236 return !_result->Empty();
239 template <
typename Promise>
240 YACLIB_INLINE
bool await_suspend(yaclib_std::coroutine_handle<Promise> handle)
const noexcept {
241 return _result->SetCallback(handle.promise());
245 return std::as_const(_result->Get()).Ok();
virtual void Submit(Job &job) noexcept=0
Submit given job.
A intrusive pointer to objects with an embedded reference count.
static constexpr auto kShared
InlineCore * Here(InlineCore &caller) noexcept final
AwaitEvent & GetCall() noexcept
AwaitSingleAwaiter(UniqueCorePtr< V, E > &&result) noexcept
YACLIB_INLINE bool await_suspend(yaclib_std::coroutine_handle< Promise > handle) noexcept
YACLIB_INLINE bool await_ready() const noexcept
YACLIB_INLINE bool await_suspend(yaclib_std::coroutine_handle< Promise > handle) const noexcept
auto await_resume() const
YACLIB_INLINE bool await_ready() const noexcept
AwaitSingleAwaiter(SharedCorePtr< V, E > result) noexcept
bool Empty() const noexcept
YACLIB_INLINE bool await_suspend(yaclib_std::coroutine_handle< Promise > handle) noexcept
static constexpr auto kShared
MultiAwaitAwaiter(Handles... handles) noexcept
MultiAwaitAwaiter(It it, std::size_t count) noexcept
constexpr void await_resume() const noexcept
YACLIB_INLINE bool await_ready() const noexcept
#define YACLIB_ASSERT(cond)
YACLIB_INLINE BaseCore * MoveToCaller(BaseCore *head) noexcept
void SetCallbacksStatic(Event &event, Handles... handles)
YACLIB_INLINE void Loop(InlineCore *prev, InlineCore *curr) noexcept
void SetCallbacksDynamic(Event &event, It it, std::size_t count)
Contract< V, E > MakeContract()
Creates related future and promise.
YACLIB_INLINE bool SubEqual(std::size_t n) noexcept
AwaitAwaiterBase(Handle caller) noexcept
YACLIB_INLINE bool await_ready() const noexcept
constexpr void await_resume() const noexcept
YACLIB_INLINE bool await_suspend(yaclib_std::coroutine_handle< Promise > handle) noexcept
InlineCore * Here(InlineCore &caller) noexcept final
YACLIB_INLINE bool await_suspend(yaclib_std::coroutine_handle< Promise > handle) noexcept
void Call() noexcept final
constexpr bool await_ready() const noexcept
constexpr void await_resume() const noexcept
TransferAwaiter(BaseCore &caller) noexcept
YACLIB_INLINE auto await_suspend(yaclib_std::coroutine_handle< Promise > handle) noexcept
YACLIB_INLINE auto await_suspend(yaclib_std::coroutine_handle< Promise > handle) noexcept
TransferSingleAwaiter(UniqueCorePtr< V, E > &&result) noexcept
constexpr bool await_ready() const noexcept