#include <mp-coro/bits/synchronized_task.h>
Lazy task that can later be started explicitly, and that notifies another variable (the “sync” object) of its completion.
This class doesn't spawn any threads itself, it just defines a coroutine with the notification of the “sync” object as its continuation.
Definition at line 39 of file synchronized_task.h.
Classes | |
struct | promise_type |
Required promise type for coroutines returning a synchronized_task. More... | |
Public Types | |
using | value_type = T |
The type of the value produced by this synchronized_task. More... | |
Public Member Functions | |
synchronized_task (synchronized_task &&)=default | |
Move constructor. More... | |
synchronized_task & | operator= (synchronized_task &&)=delete |
Move assignment not allowed. More... | |
void | start (Sync &s) |
Start (resume) execution of the synchronized_task. More... | |
decltype(auto) | get () const & |
Get the value produced by this task. More... | |
decltype(auto) | get () const && |
Get the value produced by this task. More... | |
decltype(auto) | nonvoid_get () const & |
Get the value produced by this task. More... | |
decltype(auto) | nonvoid_get () const && |
Get the value produced by this task. More... | |
Private Member Functions | |
synchronized_task (promise_type *promise) | |
Private constructor used in promise_type::get_return_object. More... | |
Private Attributes | |
promise_ptr< promise_type > | promise_ |
An owning pointer to the promise object in the coroutine frame. More... | |
Related Functions | |
(Note that these are not member functions.) | |
template<sync_notification_type Sync, awaitable A> | |
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. More... | |
using value_type = T |
The type of the value produced by this synchronized_task.
Definition at line 42 of file synchronized_task.h.
|
default |
Move constructor.
|
inlineprivate |
Private constructor used in promise_type::get_return_object.
Definition at line 126 of file synchronized_task.h.
|
delete |
Move assignment not allowed.
|
inline |
Start (resume) execution of the synchronized_task.
s | Reference to the “sync” object, i.e. the variable to notify of the task's completion. When the task is suspended at its final suspension point, s.notify_awaitable_completed() is called. |
s.notify_awaitable_completed()
is called directly in promise_type::final_awaiter::await_suspend(), it does not (and cannot) use Symmetric Control Transfer. Definition at line 91 of file synchronized_task.h.
|
inline |
Get the value produced by this task.
Must be called after the “sync” object passed to start() has been notified.
Definition at line 99 of file synchronized_task.h.
|
inline |
Get the value produced by this task.
Must be called after the “sync” object passed to start() has been notified.
Definition at line 104 of file synchronized_task.h.
|
inline |
Get the value produced by this task.
Must be called after the “sync” object passed to start() has been notified.
Definition at line 109 of file synchronized_task.h.
|
inline |
Get the value produced by this task.
Must be called after the “sync” object passed to start() has been notified.
Definition at line 114 of file synchronized_task.h.
|
related |
Coroutine returning an synchronized_task that awaits the given awaitable and returns its result.
Definition at line 135 of file synchronized_task.h.
|
private |
An owning pointer to the promise object in the coroutine frame.
When the task is destructed, this will cause the coroutine frame to be destroyed automatically.
Definition at line 123 of file synchronized_task.h.