Skip to main content

Module clock

Module clock 

Source
Expand description

The one time source this crate reads.

Core never calls the system clock. Every instant it stamps, and every comparison it makes against one, is read through a Clock, so that a test drives time by advancing this one dependency alone.

A clock has two readings, and they answer different questions. Clock::now is the wall clock: every instant this crate records — an action’s request, an event’s arrival, an intervention’s persisted deadline — is stamped from it, so that the history reads in the absolute time it was written. Clock::elapsed is a clock nothing steps, and every duration measured while the supervisor lives is measured on it: a bounded intervention’s expiry, the agent’s minimum interval between changes to the machine, and the detector’s resume grace. A host’s wall clock is moved by time synchronisation, and a duration measured across one such step is cut short or drawn out by the step.

The two meet only where a recorded instant has to become a live wait: an intervention’s persisted deadline, or the instant the agent last acted, read back after a restart. Each is translated once, against a ClockReading that took both readings together, and is counted down on Clock::elapsed from then on.

Structs§

ClockReading
Both of a clock’s readings, taken together.
SystemClock
The system’s own clock, which is what a running supervisor is given.

Traits§

Clock
The instant core reads the current time from.

Functions§

plus_seconds
The instant seconds after instant.
seconds_between
How many whole seconds later is after earlier, saturating.
unix_seconds
One instant as whole seconds after the Unix epoch.