std1.0.0-beta-7 SafeC docs

std :: dsp::timer_wheel

Struct std::WheelTimer

#include <std/dsp/timer_wheel.h> source

struct WheelTimer {
    unsigned long expires;
    ?fn void(?&Erased) callback;
    ?&Erased ctx;
    int used;
    int periodic;
    unsigned long period;
}

Fields

§unsigned long expiressource

absolute tick when the timer fires

§?fn void(?&Erased) callbacksource

One TimerWheel is a multi-tenant scheduler: its slots host timers with unrelated context types at once, so each slot stores its callback and context type-erased. They are only ever written by TimerWheel::add/add_periodic below, which take a matching fn void(?&T) / ?&T pair, so the erased call is always well-typed (see std/erased.h).

the fn void(?&T); null when free

the ?&T

§int usedsource

1 if slot occupied, 0 if free

§int periodicsource

1 → auto-reschedule every period ticks

§unsigned long periodsource

interval for periodic timers