File tree Expand file tree Collapse file tree
crates/nexum-runtime/src/test_utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -44,7 +44,10 @@ impl ManualClock {
4444 }
4545 }
4646
47- /// Pin wall time to `time`. Times before the Unix epoch clamp to it.
47+ /// Pin wall time to `time`, leaving the monotonic reading untouched.
48+ /// Times before the Unix epoch clamp to it. Because it does not move
49+ /// monotonic, a `set` after an `advance` can put wall time behind the
50+ /// monotonic source; the two only stay in step under `advance`.
4851 pub fn set ( & self , time : SystemTime ) {
4952 let wall = time. duration_since ( UNIX_EPOCH ) . unwrap_or ( Duration :: ZERO ) ;
5053 self . locked ( ) . wall = wall;
@@ -59,7 +62,11 @@ impl ManualClock {
5962 }
6063
6164 /// Build a [`WasiClockOverride`] backed by this clock for both the wall and
62- /// monotonic sources.
65+ /// monotonic sources. The two `Arc`s wrap separate `clone`s of the same
66+ /// `ManualClock`, which share one inner `Arc<Mutex<_>>`, so both handles
67+ /// read and drive the same time. Swapping a `clone` for a fresh
68+ /// `ManualClock::new()` would split that state and silently break the
69+ /// override.
6370 pub fn as_override ( & self ) -> WasiClockOverride {
6471 WasiClockOverride :: new ( Arc :: new ( self . clone ( ) ) , Arc :: new ( self . clone ( ) ) )
6572 }
You can’t perform that action at this time.
0 commit comments