aboutsummaryrefslogtreecommitdiff
path: root/src/time/clock.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/time/clock.rs')
-rw-r--r--src/time/clock.rs15
1 files changed, 2 insertions, 13 deletions
diff --git a/src/time/clock.rs b/src/time/clock.rs
index 8957800..c5ef86b 100644
--- a/src/time/clock.rs
+++ b/src/time/clock.rs
@@ -120,22 +120,11 @@ cfg_test_util! {
/// Panics if time is not frozen or if called from outside of the Tokio
/// runtime.
pub async fn advance(duration: Duration) {
- use crate::future::poll_fn;
- use std::task::Poll;
-
let clock = clock().expect("time cannot be frozen from outside the Tokio runtime");
+ let until = clock.now() + duration;
clock.advance(duration);
- let mut yielded = false;
- poll_fn(|cx| {
- if yielded {
- Poll::Ready(())
- } else {
- yielded = true;
- cx.waker().wake_by_ref();
- Poll::Pending
- }
- }).await;
+ crate::time::sleep_until(until).await;
}
/// Return the current instant, factoring in frozen time.