DeadlineWatchdog
struct DeadlineWatchdogOne background thread enforcing per-slot deadlines.
Arm a slot with arm(slot, budget_ms, cancel_addr) before running
a cooperative handler and disarm(slot) after it returns; the
watchdog flips the cell if the budget elapses first. stop()
halts and joins the thread. For a process-lifetime server watchdog,
construct once and leak it (never stop) -- one background thread
for the process is negligible.
Implements Movable
__init__
def __init__(out self, poll_ms: Int = Int(1)) Allocate the control block and spawn the watchdog thread.
arm
def arm(self, slot: Int, budget_ms: Int, cancel_addr: Int) Arm slot to flip the cell at cancel_addr in budget_ms from now. A budget that is already spent (<= 0 or in the past) fires at the next poll; one that would overflow never fires.
disarm
def disarm(self, slot: Int) -> Bool Disarm slot; True if the watchdog had already fired it. See :func:watchdog_disarm.
stop
def stop(mut self) Stop the watchdog thread, join it, and free the block.