#include <dispatcher_base.h>
Public Member Functions | |
Waker (Waker &&other) noexcept | |
Waker & | operator= (Waker &&other) noexcept |
void | Wake () && |
void | InternalCloneInto (Waker &waker_out) & |
bool | IsEmpty () const |
void | Clear () |
Friends | |
class | Task |
class | NativeDispatcherBase |
An object which can respond to asynchronous events by queueing work to be done in response, such as placing a Task
on a Dispatcher
loop.
Waker
s are often held by I/O objects, custom concurrency primitives, or interrupt handlers. Once the thing the Task
was waiting for is available, Wake
should be called so that the Task
is alerted and may process the event.
Waker
s may be held for any lifetime, and will be automatically nullified when the underlying Dispatcher
or Task
is deleted.
Waker
s are most commonly created by Dispatcher
s, which pass them into Task::Pend
via its Context
argument.
|
inline |
Clears this Waker
.
After this call, Wake
will no longer perform any action, and IsEmpty
will return true
.
This operation is guaranteed to be thread-safe.
void pw::async2::Waker::InternalCloneInto | ( | Waker & | waker_out | ) | & |
bool pw::async2::Waker::IsEmpty | ( | ) | const |
Returns whether this Waker
is empty.
Empty wakers are those that perform no action upon wake. These may be created either via the default no-argument constructor or by calling Clear
or std::move
on a Waker
, after which the moved-from Waker
will be empty.
This operation is guaranteed to be thread-safe.
Replace this Waker
with another.
This operation is guaranteed to be thread-safe.
void pw::async2::Waker::Wake | ( | ) | && |
Wakes up the Waker
's creator, alerting it that an asynchronous event has occurred that may allow it to make progress.
Wake
operates on an rvalue reference (&&
) in order to indicate that the event that was waited on has been complete. This makes it possible to track the outstanding events that may cause a Task
to wake up and make progress.
This operation is guaranteed to be thread-safe.