19 template <
typename Promise>
20 YACLIB_INLINE
auto await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
21 _caller.StoreCallback(handle.promise());
23#if YACLIB_SYMMETRIC_TRANSFER != 0
24 return next->Next(handle.promise());
26 return Loop(&handle.promise(), next);
37template <
typename V,
typename E>
47 template <
typename Promise>
48 YACLIB_INLINE
auto await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
49 _result->StoreCallback(handle.promise());
51#if YACLIB_SYMMETRIC_TRANSFER != 0
52 return next->Next(handle.promise());
54 return Loop(&handle.promise(), next);
59 return std::move(_result->Get()).Ok();
75 return !_caller.Empty();
78 template <
typename Promise>
79 YACLIB_INLINE
bool await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
80 return _caller.SetCallback(handle.promise());
95 template <
bool SymmetricTransfer>
111#if YACLIB_SYMMETRIC_TRANSFER != 0
121 template <
typename... Cores>
124 template <
typename It>
125 explicit AwaitAwaiter(It it, std::size_t count)
noexcept;
128 return _event.GetRef() == 1;
131 template <
typename Promise>
132 YACLIB_INLINE
bool await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
133 _event.next = &handle.promise();
134 return !_event.SubEqual(1);
144template <
typename...
Cores>
146 static_assert(
sizeof...(cores) >= 2,
"Number of futures must be at least two");
147 static_assert((... && std::is_same_v<BaseCore, Cores>),
"Futures must be Future in Wait function");
148 const auto wait_count = (... +
static_cast<std::size_t
>(
cores.SetCallback(_event)));
152template <
typename It>
155 for (std::size_t
i = 0;
i != count; ++
i) {
157 wait_count +=
static_cast<std::size_t
>(
it->GetCore()->SetCallback(_event));
160 _event.count.fetch_sub(count -
wait_count, std::memory_order_relaxed);
163template <
typename V,
typename E>
171 return !_result->Empty();
174 template <
typename Promise>
175 YACLIB_INLINE
bool await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
176 return _result->SetCallback(handle.promise());
180 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