YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
on_awaiter.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
yaclib/coro/coro.hpp
>
4
#include <
yaclib/coro/detail/promise_type.hpp
>
5
#include <
yaclib/exe/executor.hpp
>
6
#include <
yaclib/exe/job.hpp
>
7
8
namespace
yaclib::detail
{
9
10
class
[[
nodiscard
]]
OnAwaiter
final
{
11
public
:
12
YACLIB_INLINE
explicit
OnAwaiter
(
IExecutor
& e) noexcept : _executor{e} {
13
}
14
15
constexpr
bool
await_ready
() const noexcept {
16
return
false
;
17
}
18
19
template
<
typename
Promise>
20
YACLIB_INLINE
void
await_suspend
(yaclib_std::coroutine_handle<Promise> handle)
const
noexcept
{
21
auto
& promise = handle.promise();
22
promise._executor = &_executor;
23
_executor.Submit(promise);
24
}
25
26
constexpr
void
await_resume
() const noexcept {
27
}
28
29
private
:
30
IExecutor
& _executor;
31
};
32
33
}
// namespace yaclib::detail
yaclib::IExecutor
Definition
executor.hpp:8
yaclib::detail::OnAwaiter
Definition
on_awaiter.hpp:10
yaclib::detail::OnAwaiter::await_suspend
YACLIB_INLINE void await_suspend(yaclib_std::coroutine_handle< Promise > handle) const noexcept
Definition
on_awaiter.hpp:20
yaclib::detail::OnAwaiter::await_ready
constexpr bool await_ready() const noexcept
Definition
on_awaiter.hpp:15
yaclib::detail::OnAwaiter::OnAwaiter
YACLIB_INLINE OnAwaiter(IExecutor &e) noexcept
Definition
on_awaiter.hpp:12
yaclib::detail::OnAwaiter::await_resume
constexpr void await_resume() const noexcept
Definition
on_awaiter.hpp:26
coro.hpp
executor.hpp
job.hpp
yaclib::detail
Definition
base_core.hpp:18
yaclib::MakeContract
Contract< V, E > MakeContract()
Creates related future and promise.
Definition
contract.hpp:25
promise_type.hpp
include
yaclib
coro
detail
on_awaiter.hpp
Generated by
1.9.8