From 53fbf3051458fe249aa51fdeea9c000b719f23ba Mon Sep 17 00:00:00 2001 From: datdenkikniet Date: Mon, 10 Apr 2023 13:09:50 +0200 Subject: [PATCH] Clean up --- rtic-time/tests/timer_queue.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/rtic-time/tests/timer_queue.rs b/rtic-time/tests/timer_queue.rs index 7b233740b0..4f285e010a 100644 --- a/rtic-time/tests/timer_queue.rs +++ b/rtic-time/tests/timer_queue.rs @@ -75,19 +75,11 @@ impl Instant { NOW.lock().clone().unwrap_or(Instant::ZERO) } - pub fn from_ticks(ticks: u64) -> Self { - Self(ticks) - } - - pub fn as_ticks(&self) -> u64 { - self.0 - } - pub fn elapsed(&self) -> Duration { Duration(Self::now().0 - self.0) } - pub async fn sleep_until(time: Instant) { + pub async fn wait_until(time: Instant) { core::future::poll_fn(|ctx| { if Instant::now() >= time { Poll::Ready(()) @@ -102,7 +94,7 @@ impl Instant { impl From for Instant { fn from(value: u64) -> Self { - Self::from_ticks(value) + Self(value) } } @@ -206,8 +198,11 @@ fn timer_queue() { let total_millis = total.as_ticks(); async move { + // A `pre_delay` simulates a delay in scheduling, + // without the `pre_delay` being present in the timer + // queue if let Some(pre_delay) = pre_delay { - Instant::sleep_until(start + pre_delay).await; + Instant::wait_until(start + pre_delay).await; } TestMono::queue().delay(delay).await;