std1.0.0-beta-7 SafeC docs

std :: async::executor

Struct std::LocalExecutor

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

struct LocalExecutor {
    ?&TaskHeader head;
    ?&TaskHeader tail;
    int live;
    int notified;
    int root_woken;
    struct TimerQueue timers;
    long long polls;
}

The single-threaded, no-heap executor (see the top of this file).

Fields

live tasks, in spawn order

§int livesource

spawned and not finished

§int notifiedsource

atomic: some task (or the block_on root) was woken

§int root_wokensource

atomic: block_on's own future was woken

§struct TimerQueue timerssource
§long long pollssource

statistics: task polls so far

Methods

§static struct LocalExecutor new()source · definition
§generic<F, T> struct JoinHandle<T> spawn(&AsyncTask<F, T> task)source · definition

Start running 'task' (returns its handle). The task joins the end of the poll order and is polled on the next round.

§int run_ready()source · definition

One round: poll every task woken when its turn in the spawn order comes (a task woken by one later in the order waits for the next round). Doesn't advance the timers or wait. Returns the polls made.

§int turn(long long now_ms)source · definition

Advance the timer queue to now_ms (firing what is due), then one round. Returns the polls made.

§generic<P: Park> void run(&P park)source · definition

Run until every spawned task has finished: rounds, with the timers advanced by the Park's clock before each, parking on 'park' whenever nothing is runnable. A task that keeps waking itself doesn't stop timers from firing.

§generic<P: Park, F: Future, T> T block_on(&P park, &F fut)source · definition

Run 'fut' (and every spawned task, meanwhile) until 'fut' is Ready; returns its value. Spawned tasks that are still running stay spawned.

§int live_count() constsource · definition
§int has_ready() constsource · definition

some task is woken

§void drop()source · definition

Releases the timer queue. Spawned tasks are owned by their AsyncTask storage, not by the executor: finish or abort them first.