std1.0.0-beta-7 SafeC docs

std :: async::future

Struct std::Context

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

struct Context {
    struct Waker waker;
    ?&TimerQueue timers;
}

What poll() gets: the waker of the task being polled, and the services of the executor polling it. Executors fill it in for every poll; a future only reads it (and clones the waker if it needs to keep it).

timers  the executor's timer queue (std/async/timer.h): Sleep,
        Interval and Timeout register there. null when the executor
        has none (Context::from_waker), and then sleeping is an error.
io_     the executor's I/O driver (std/async/net.h's IoDriver), or
        null: the futures there read it through io_driver(cx).
exec_, spawn_  the executor, and its spawn function (see
        std/erased.h): what async_spawn uses to start another task
        from inside a task. Set by the executor through
        context_set_spawn_ (std/async/executor.h).

Fields

§struct Waker wakersource

Methods

§static struct Context from_waker(struct Waker w)source · definition

A context with only a waker: no timers, no I/O, no spawning.

§static struct Context noop()source · definition

A context with Waker::noop(): poll by hand and look at the result.

§void wake_by_ref() constsource · definition

waker.wake_by_ref(): "poll me again soon"

§void drop()source · definition

Releases the waker. A Context owns its waker (a Drop value), so the executor that made one drops it after the poll.