Skip to main content

Module clock

Module clock 

Source
Expand description

Where the session’s sense of time comes from.

§Why a port and not Instant::now

The session engine decides that a request has outlived its budget, and that decision is arithmetic over two readings. If it took the second reading from a global clock, a test could not set up a request that started 90 seconds ago without sleeping for 90 seconds, and a deterministic domain would stop being one. Everything else follows from this: the clock is injected, the reading is a std::time::Duration from an origin the adapter chose, and no session code calls a clock function at all.

§Why the origin is the adapter’s business

Two sessions opened in the same millisecond must still be distinguishable, and a wall clock can step backwards under NTP. A duration from a monotonic source has neither problem, and which monotonic source is the transport’s problem — Instant against process start, a monotonic clock value, a virtual time in a test.

Traits§

Clock
A monotonic source of time.