flare_mlake · API · runtime

flare.runtime.scheduler_stats

Cross-thread stop flag and per-worker stats cell.

Shared by scheduler.mojo (which allocates and reads them) and _worker.mojo (which writes them), so they live here rather than in either -- importing one from the other would be a cycle.

scheduler.mojo re-exports every name below, so the existing from flare.runtime.scheduler import load_stop_flag call sites in the reactor loops keep working unchanged.

Functions

store_stop_flag

def store_stop_flag(addr: Int, value: Bool)

Release-store value into the heap stop-flag byte at addr.

load_stop_flag

def load_stop_flag(addr: Int) -> Bool

Acquire-load the heap stop-flag byte at addr.

store_worker_stat

def store_worker_stat(base_addr: Int, slot: Int, value: Int)

Release-store value into slot of the worker stats cell.

load_worker_stat

def load_worker_stat(base_addr: Int, slot: Int) -> Int

Acquire-load slot of the worker stats cell (0 when disabled).

Aliases

comptime WORKER_STAT_INFLIGHT = Int(0)

Slot index: connections still registered on this worker.

comptime WORKER_STAT_STATUS = Int(1)

Slot index: worker exit status (see WORKER_STATUS_*).

comptime WORKER_STAT_DONE = Int(2)

Slot index: 1 once the worker's thread has returned from run_worker, whatever the frontend reported. Scheduler.drain waits on it with a deadline instead of blocking in pthread_join.

comptime WORKER_STAT_GROUP = Int(3)

Slot index: address of the scheduler's accept-balancing group block (flare.runtime._balance), or 0 when balancing is off.

comptime WORKER_STAT_INDEX = Int(4)

Slot index: this worker's index inside the balancing group.

comptime WORKER_STAT_SLOTS = Int(5)

Number of Int64 slots per worker cell.

comptime WORKER_STATUS_RUNNING = Int(0)

Worker has not exited its serve loop yet.

comptime WORKER_STATUS_CLEAN = Int(1)

Worker exited because it observed the stop flag (normal shutdown).

comptime WORKER_STATUS_CRASHED = Int(2)

Worker exited because its reactor poll failed (unexpected).