diff options
Diffstat (limited to 'src/time.rs')
| -rw-r--r-- | src/time.rs | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/time.rs b/src/time.rs index 4abb3f9..a05c0e7 100644 --- a/src/time.rs +++ b/src/time.rs @@ -39,11 +39,8 @@ thread_local! { /// Freeze the clock for this thread, returning the previous pin if any. /// -/// Test-tier only, together with `unpin` — the two are one capability and -/// gating half of it would leave a release binary able to freeze time and -/// unable to release it. The census never reported `pin` as test-only because -/// its name match also fires inside `upstream_pins` and `source_digests`; the -/// only callers in the crate are tests. +/// Gated with `unpin`: they are one capability, and gating half would leave a +/// release binary able to freeze time and unable to release it. #[cfg(feature = "test-support")] pub fn pin(ts: &str) -> Option<String> { CLOCK.with(|c| { @@ -52,7 +49,7 @@ pub fn pin(ts: &str) -> Option<String> { }) } -/// Release a pin set by `pin`. See the note there about why both are gated. +/// Release a pin set by `pin`. #[cfg(feature = "test-support")] pub fn unpin() { CLOCK.with(|c| *c.borrow_mut() = None); @@ -76,8 +73,6 @@ pub fn secs_ahead(secs: i64) -> String { fmt(base() + chrono::Duration::seconds(secs)) } -// ---- waiting ---- - /// Wait for `d`, checking `stop` every `slice`. Returns false if `stop` was set /// before the wait finished, so a control loop can leave instead of doing one /// more pass. @@ -105,8 +100,8 @@ pub fn sleep(d: Duration) { } /// Wrap a closure about to be spawned so the child thread inherits this one's -/// clock setting. Without it a control loop spawned by a test runs on wall time -/// while the test itself runs on the virtual clock, and the two disagree. +/// clock setting; a spawned control loop on wall time would disagree with a +/// test on the virtual clock. pub fn inherit<F, T>(f: F) -> impl FnOnce() -> T where F: FnOnce() -> T + Send + 'static, @@ -138,7 +133,7 @@ mod clock { static AT: Mutex<Option<DateTime<Utc>>> = Mutex::new(None); static OWNER: Mutex<()> = Mutex::new(()); - // VirtualClock stays `pub`: lives in the `test-support`-gated clock module, behind the gated `virtualize()` that returns it. + // `pub` only because the gated `virtualize()` that returns it is `pub`. pub struct VirtualClock { // Held, never read: owning the mutex *is* the virtual clock's lease, // and dropping this guard is what releases it. @@ -216,10 +211,6 @@ mod clock { mod tests { use super::*; - // Moved verbatim from tests/time.rs. These two are arithmetic on the - // clock itself and need nothing else; the third test in that file pins a - // lease against a pinned clock, which needs a database, so it stayed. - #[cfg(feature = "test-support")] #[test] fn a_pinned_clock_moves_relative_arithmetic_with_it() { |
