Skip to main content

Module clock

Module clock 

Expand description

Time, injected rather than read.

Nothing in atune_core calls std::time directly. Every timestamp — trial creation, completion, heartbeats, walltime budgets — comes from a Clock handed in by the caller. Two reasons, both load-bearing:

  • wasm. wasm32-unknown-unknown has no wall clock; SystemTime::now() panics there. Keeping time behind a trait is what lets cargo check -p atune_core --target wasm32-unknown-unknown --no-default-features stay green.
  • Determinism. Tests drive ManualClock and get reproducible heartbeat, deadline and fail-over behaviour instead of sleeping.

SystemClock is the production implementation and lives behind the system feature. ManualClock is always available.

Structs§

ManualClock
A clock that only moves when a test moves it.
SystemClock
The operating system’s wall clock, in milliseconds since the Unix epoch.

Traits§

Clock
A source of milliseconds.