summaryrefslogtreecommitdiffstats
path: root/src/time.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/time.rs')
-rw-r--r--src/time.rs27
1 files changed, 6 insertions, 21 deletions
diff --git a/src/time.rs b/src/time.rs
index 7587721..29206d6 100644
--- a/src/time.rs
+++ b/src/time.rs
@@ -110,21 +110,14 @@ where
clock::wrap(f)
}
+/// The handle tests hold to keep the clock frozen; dropping it releases the
+/// clock, which is why `virtualize` hands one back rather than setting a global.
#[cfg(feature = "test-support")]
-pub fn virtualize() -> clock::VirtualClock {
- clock::virtualize()
-}
-
-#[cfg(feature = "test-support")]
-pub fn virtual_now() -> Option<DateTime<Utc>> {
- clock::now()
-}
+pub use clock::VirtualClock;
-/// Move the frozen clock along, so a control loop can be made to believe a tick,
-/// a lease or a cooldown has elapsed without anything waiting for it.
#[cfg(feature = "test-support")]
-pub fn advance(d: Duration) {
- clock::advance(d)
+pub fn virtualize() -> clock::VirtualClock {
+ clock::virtualize()
}
#[cfg(feature = "test-support")]
@@ -181,15 +174,7 @@ mod clock {
true
}
- pub fn advance(d: Duration) {
- let mut at = lock(&AT);
- if let Some(t) = *at {
- let step = chrono::TimeDelta::from_std(d).unwrap_or_else(|_| chrono::TimeDelta::zero());
- *at = Some(t + step);
- }
- }
-
- pub fn wrap<F, T>(f: F) -> impl FnOnce() -> T
+ pub(super) fn wrap<F, T>(f: F) -> impl FnOnce() -> T
where
F: FnOnce() -> T + Send + 'static,
T: Send + 'static,