std1.0.0-beta-7 SafeC docs

std :: async::future

Struct std::Waker

#include <std/async/future.h> source

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 · definition

A 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 · definition

A waker whose copies are counted: clone(data, tag) runs for every clone(), drop(data, tag) for every drop() (and after wake()).

§static struct Waker noop()source · definition

A waker that does nothing (Rust's Waker::noop): for polling a future by hand, in tests, or where nobody needs to be told.

§void wake() consumesource · definition

wake_by_ref(), then drop()

§void wake_by_ref() constsource · definition
§struct Waker clone() constsource · definition
§void drop()source · definition
§int will_wake(const &Waker other) constsource · definition

True if both wake the same task (same data, functions and tag): lets a future skip re-registering an unchanged waker.

§int is_noop() constsource · definition