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
6#include <yaclib/exe/job.hpp>
7
8namespace yaclib::detail {
9
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_INLINE void await_suspend(yaclib_std::coroutine_handle< Promise > handle) const noexcept
constexpr bool await_ready() const noexcept
YACLIB_INLINE OnAwaiter(IExecutor &e) noexcept
constexpr void await_resume() const noexcept
Contract< V, E > MakeContract()
Creates related future and promise.
Definition contract.hpp:25