std :: async::future
Struct std::Waker
struct Waker { }A handle that tells an executor "poll the task this belongs to again". It is a type-erased (data, functions) pair, like Rust's RawWaker and its vtable (see std/erased.h), made only through the generic constructors below, which take a matching fn(?&T, ...) and ?&T so every erased call is well-typed:
wake (data, tag): schedule the task. Called by wake/wake_by_ref.
clone, drop (data, tag): a copy of this waker was made / let go of —
for executors whose wakers own a reference count. null
(Waker::new) when copies are free, as for every executor in
std/async: their wakers point at task storage that outlives
every registration (a future unregisters in drop()).
Wakers are small values; copy them with clone() (which runs the clone hook) and release them with drop(). wake() consumes the waker, wake_by_ref() doesn't.
Methods
generic<T> static struct Waker new(
fn void(?&T, unsigned long) wake,
?&T data,
unsigned long tag,
)source · definitionA waker calling wake(data, tag); copies need no bookkeeping.
generic<T> static struct Waker counted(
fn void(?&T, unsigned long) wake,
fn void(?&T, unsigned long) clone,
fn void(?&T, unsigned long) drop,
?&T data,
unsigned long tag,
)source · definitionA waker whose copies are counted: clone(data, tag) runs for every clone(), drop(data, tag) for every drop() (and after wake()).
A waker that does nothing (Rust's Waker::noop): for polling a future by hand, in tests, or where nobody needs to be told.
wake_by_ref(), then drop()
True if both wake the same task (same data, functions and tag): lets a future skip re-registering an unchanged waker.