25 template <
bool SymmetricTransfer>
30 if (this->SubEqual(1)) {
37 [[
nodiscard]] InlineCore* Here(InlineCore& caller)
noexcept final {
40#if YACLIB_SYMMETRIC_TRANSFER != 0
41 [[
nodiscard]] yaclib_std::coroutine_handle<>
Next(InlineCore& caller)
noexcept final {
57 template <
typename Promise>
58 YACLIB_INLINE
void await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
59 auto& core = handle.promise();
60 core._executor = &_executor;
61 auto* caller = _event.job;
64 if (!caller->SetCallback(_event)) {
65 _executor.Submit(core);
80 template <
typename... Cores>
83 template <
typename It>
90 template <
typename Promise>
91 YACLIB_INLINE
void await_suspend(yaclib_std::coroutine_handle<Promise> handle)
noexcept {
92 auto& core = handle.promise();
93 core._executor = &_executor;
96 if (_event.SubEqual(1)) {
97 _executor.Submit(core);
109template <
typename...
Cores>
111 : _executor{
e}, _event{
sizeof...(cores) + 1} {
112 static_assert(
sizeof...(cores) >= 2,
"Number of futures must be at least two");
113 static_assert((... && std::is_same_v<BaseCore, Cores>),
"Futures must be Future in Wait function");
114 const auto wait_count = (... +
static_cast<std::size_t
>(
cores.SetCallback(_event)));
115 _event.count.fetch_sub(
sizeof...(
cores) -
wait_count, std::memory_order_relaxed);
118template <
typename It>
120 : _executor{
e}, _event{count + 1} {
122 for (std::size_t
i = 0;
i != count; ++
i) {
123 wait_count +=
static_cast<std::size_t
>(
it->GetCore()->SetCallback(_event));
126 _event.count.fetch_sub(count -
wait_count, std::memory_order_relaxed);
virtual void Submit(Job &job) noexcept=0
Submit given job.
YACLIB_INLINE void await_suspend(yaclib_std::coroutine_handle< Promise > handle) noexcept
constexpr void await_resume() const noexcept
constexpr bool await_ready() const noexcept
AwaitOnEvent(std::size_t n) noexcept
#define YACLIB_ASSERT(cond)
std::conditional_t< Single, OneCounter< NopeBase, NopeDeleter >, AtomicCounter< NopeBase, NopeDeleter > > AwaitOnCounterT
Contract< V, E > MakeContract()
Creates related future and promise.
constexpr void await_resume() const noexcept
YACLIB_INLINE void await_suspend(yaclib_std::coroutine_handle< Promise > handle) noexcept
AwaitOnAwaiter(IExecutor &e, BaseCore &caller) noexcept
constexpr bool await_ready() const noexcept