20 template <
typename Promise>
21 YACLIB_INLINE
auto await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
22 _caller.StoreCallback(handle.promise());
24#if YACLIB_SYMMETRIC_TRANSFER != 0
25 return next->Next(handle.promise());
27 return Loop(&handle.promise(), next);
38template <
typename V,
typename E>
49 template <
typename Promise>
50 YACLIB_INLINE
auto await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
51 _result->StoreCallback(handle.promise());
53#if YACLIB_SYMMETRIC_TRANSFER != 0
54 return next->Next(handle.promise());
56 return Loop(&handle.promise(), next);
61 return std::move(_result->Get()).Ok();
77 return !_caller.Empty();
80 template <
typename Promise>
81 YACLIB_INLINE
bool await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
82 return _caller.SetCallback(handle.promise());
97 template <
bool SymmetricTransfer>
113#if YACLIB_SYMMETRIC_TRANSFER != 0
123 template <
typename... Cores>
126 template <
typename It>
127 explicit AwaitAwaiter(It it, std::size_t count)
noexcept;
130 return _event.Get(std::memory_order_acquire) == 1;
133 template <
typename Promise>
134 YACLIB_INLINE
bool await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
135 _event.next = &handle.promise();
136 return !_event.SubEqual(1);
146template <
typename...
Cores>
148 static_assert(
sizeof...(cores) >= 2,
"Number of futures must be at least two");
149 static_assert((... && std::is_same_v<BaseCore, Cores>),
"Futures must be Future in Wait function");
150 const auto wait_count = (... +
static_cast<std::size_t
>(
cores.SetCallback(_event)));
154template <
typename It>
157 for (std::size_t
i = 0;
i != count; ++
i) {
159 wait_count +=
static_cast<std::size_t
>(
it->GetCore()->SetCallback(_event));
162 _event.count.fetch_sub(count -
wait_count, std::memory_order_relaxed);
165template <
typename V,
typename E>
173 return !_result->Empty();
176 template <
typename Promise>
177 YACLIB_INLINE
bool await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
178 return _result->SetCallback(handle.promise());
182 return std::move(_result->Get()).Ok();
A intrusive pointer to objects with an embedded reference count.
YACLIB_INLINE bool await_suspend(yaclib_std::coroutine_handle< Promise > handle) noexcept
YACLIB_INLINE bool await_ready() const noexcept
constexpr void await_resume() const noexcept
AwaitSingleAwaiter(ResultCorePtr< V, E > &&result) noexcept
YACLIB_INLINE bool await_ready() const noexcept
YACLIB_INLINE bool await_suspend(yaclib_std::coroutine_handle< Promise > handle) noexcept
#define YACLIB_ASSERT(cond)
YACLIB_INLINE BaseCore * MoveToCaller(BaseCore *head) noexcept
YACLIB_INLINE void Loop(InlineCore *prev, InlineCore *curr) noexcept
Contract< V, E > MakeContract()
Creates related future and promise.
YACLIB_INLINE bool SubEqual(std::size_t n) noexcept
yaclib_std::atomic_size_t count
TODO(mkornaukhov03) Add doxygen docs.
YACLIB_INLINE bool await_suspend(yaclib_std::coroutine_handle< Promise > handle) noexcept
AwaitAwaiter(BaseCore &caller) noexcept
YACLIB_INLINE bool await_ready() const noexcept
constexpr void await_resume() const noexcept
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
TransferSingleAwaiter(ResultCorePtr< V, E > &&result) noexcept
YACLIB_INLINE auto await_suspend(yaclib_std::coroutine_handle< Promise > handle) noexcept
constexpr bool await_ready() const noexcept