pub struct ManualWallClock { /* private fields */ }Expand description
A wall clock projected from a shared ManualMonotonicClock.
Advancing the monotonic clock advances this wall clock by the same
duration. Calling reanchor() changes only the wall-time
mapping and never changes the underlying monotonic clock.
Implementations§
Source§impl ManualWallClock
impl ManualWallClock
Sourcepub fn from_clock(
wall_time: SystemTime,
clock: Arc<ManualMonotonicClock>,
) -> Self
pub fn from_clock( wall_time: SystemTime, clock: Arc<ManualMonotonicClock>, ) -> Self
Creates a wall clock whose current reading is wall_time.
Future readings advance according to the explicitly shared clock.
§Parameters
wall_time- Wall-clock value assigned to the current manual instant.clock- Shared manual monotonic timeline driving future readings.
§Returns
A wall clock anchored to the supplied wall and monotonic times.
Sourcepub fn reanchor(&self, wall_time: SystemTime)
pub fn reanchor(&self, wall_time: SystemTime)
Reassigns the current monotonic instant to wall_time.
This operation may move wall time forward or backward. It does not
advance the monotonic clock and does not wake monotonic sleepers. The
anchor mutex remains held while the monotonic clock is sampled, so
concurrent calls to now() observe either the old or
the new mapping without combining both snapshots.
§Parameters
wall_time- Replacement wall time for the current monotonic instant.
Trait Implementations§
Source§impl Debug for ManualWallClock
impl Debug for ManualWallClock
Source§impl WallClock for ManualWallClock
impl WallClock for ManualWallClock
Source§fn now(&self) -> SystemTime
fn now(&self) -> SystemTime
Returns wall time derived from the anchor and current monotonic time.
§Returns
The anchored wall time plus elapsed manual monotonic time.
§Panics
Panics if the manually advanced duration cannot be represented by
SystemTime. Normal application and test durations are representable.