38template <sync_notification_type Sync, task_value_type T>
66 void await_suspend(std::coroutine_handle<promise_type> this_coro)
noexcept {
68 this_coro.promise().sync->notify_awaitable_completed();
93 std::coroutine_handle<promise_type>::from_promise(*promise_).resume();
99 [[nodiscard]]
decltype(
auto)
get()
const & {
101 return promise_->get();
104 [[nodiscard]]
decltype(
auto)
get()
const && {
106 return std::move(*promise_).get();
111 return promise_->nonvoid_get();
116 return std::move(*promise_).nonvoid_get();
133template <sync_notification_type Sync, awaitable A>
134synchronized_task<Sync, remove_rvalue_reference_t<await_result_t<A>>>
137 co_return co_await std::forward<A>(
awaitable);
Lazy task that can later be started explicitly, and that notifies another variable (the “sync” object...
decltype(auto) get() const &
Get the value produced by this task.
decltype(auto) nonvoid_get() const &&
Get the value produced by this task.
decltype(auto) get() const &&
Get the value produced by this task.
promise_ptr< promise_type > promise_
An owning pointer to the promise object in the coroutine frame.
synchronized_task & operator=(synchronized_task &&)=delete
Move assignment not allowed.
decltype(auto) nonvoid_get() const &
Get the value produced by this task.
synchronized_task< Sync, remove_rvalue_reference_t< await_result_t< A > > > make_synchronized_task(A &&awaitable)
Coroutine returning an synchronized_task that awaits the given awaitable and returns its result.
void start(Sync &s)
Start (resume) execution of the synchronized_task.
synchronized_task(synchronized_task &&)=default
Move constructor.
synchronized_task(promise_type *promise)
Private constructor used in promise_type::get_return_object.
T value_type
The type of the value produced by this synchronized_task.
std::unique_ptr< T, coro_deleter > promise_ptr
RAII wrapper that destroys promise object's associated coroutine.
Base class with deleted copy constructor and copy assignment operator.
Awaiter returned by final_suspend.
void await_suspend(std::coroutine_handle< promise_type > this_coro) noexcept
Required promise type for coroutines returning a synchronized_task.
synchronized_task get_return_object() noexcept
Returns a synchronized_task that references this promise.
static awaiter_of< void > auto final_suspend() noexcept
When awaited, notifies the “sync” object (sync) of this synchronized_task's completion.
static std::suspend_always initial_suspend() noexcept
Lazy: not started until start() is invoked explicitly.