Skip to main content

Module timer

Module timer 

Source
Expand description

Live timer scheduling and callback dispatch.

§Scheduling

Runtime waits use the time remaining until the selected UTC deadline. Fixed timers normalize an overdue initial deadline to the current time, except at an inclusive stop boundary, and use a runtime interval to deliver overdue ticks. Deadline schedules deliver a selected overdue deadline immediately with its original timestamp, then skip to the first deadline after now. They calculate each wait inside the task. Stop times are inclusive. An event whose following deadline is not representable in [UnixNanos] is the timer’s final event.

§Task lifecycle

Each LiveTimer::start creates fresh public schedule and task-state atomics. Because aborting a runtime task does not join it, task retirement linearizes restart, cancellation, and drop against event reservation. Retirement either prevents the old task from dispatching, or observes what that task reserved with its event: the following schedule, or terminal exhaustion when no successor is representable. Fresh atomics keep that task from overwriting its replacement’s schedule.

§Callback dispatch

Thread-safe callbacks cross the worker boundary as TimeEventMessage values. RustLocal callbacks remain in an owner-thread registry and cross the boundary only through tokens and leases. Senderless Python callbacks run inline and publish their following schedule, when one exists, after the callback returns.

Structs§

LiveTimer
A live timer for use with a LiveClock.