std1.0.0-beta-7 SafeC docs

std :: async::future

Struct std::TimerQueue

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

struct TimerQueue {
    struct TimerWheel wheel;
    long long origin_ms;
    int started;
    struct Spinlock lock;
    struct WaitList overflow;
    long long ovf_min;
}

The executor's timer queue (implemented in timer.sc; Sleep, Interval and the queue's role are described in std/async/timer.h). Declared here because Context points at one.

Fields

§struct TimerWheel wheelsource

tick = 1 ms since origin_ms

§long long origin_mssource

clock value of tick 0

§int startedsource

origin set (by the first advance)

§struct Spinlock locksource
§struct WaitList overflowsource

Sleeps that found the wheel full wait here, and are woken to retry when a wheel slot frees up or the earliest of their deadlines comes.

§long long ovf_minsource

earliest deadline waiting in 'overflow', -1 if none

Methods

§static struct TimerQueue new()source · definition
§int advance(long long now_ms)source · definition

Moves the queue's clock to 'now_ms' (never backwards) and wakes every timer due by then. The first call sets the origin. Returns how many fired.

§long long now_ms() constsource · definition

The current time: what the last advance() was given.

§long long next_deadline() constsource · definition

The earliest pending deadline, or -1 if no timer is pending.

§long long park_timeout() constsource · definition

Milliseconds from now to the earliest deadline (0 if already due), or -1 if no timer is pending: how long an executor may park.

§int pending() constsource · definition
§void drop()source · definition

Releases the wakers of Sleeps still waiting for a wheel slot. Every Sleep must be dropped before its queue is.