Skip to main content

Clock

Trait Clock 

Source
pub trait Clock: Send + Sync {
    // Required method
    fn now(&self) -> Timestamp;

    // Provided methods
    fn elapsed(&self) -> Duration { ... }
    fn paced(&self) -> Duration { ... }
}
Expand description

The instant core reads the current time from.

Shareable across threads, because the expiry driver reads it from a thread of its own while callers read it from theirs.

Required Methods§

Source

fn now(&self) -> Timestamp

The instant now.

Provided Methods§

Source

fn elapsed(&self) -> Duration

How much time has passed since an origin of this clock’s own, on a clock nothing steps: two readings differ by the time that passed between them, whatever the wall clock did meanwhile.

The provided reading is Clock::now’s, as time since the Unix epoch, which a step of the wall clock moves; a clock over a host’s own time answers its monotonic clock instead, as SystemClock does.

Source

fn paced(&self) -> Duration

Clock::elapsed as the agent’s minimum interval measures it.

The same reading on every clock but SystemClock in the real-print suite’s own build, where it also counts the time that suite’s replay jumps between recorded events: the agent’s changes to the machine at two events recorded an hour apart are an hour apart. Every other duration stays on Clock::elapsed, because what it spaces — the detector’s reads above all — the server takes on its own schedule in real time.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§