aboutsummaryrefslogtreecommitdiff
path: root/rtic-time
diff options
context:
space:
mode:
authordatdenkikniet <jcdra1@gmail.com>2023-04-10 13:09:50 +0200
committerdatdenkikniet <jcdra1@gmail.com>2023-04-10 13:19:23 +0200
commit53fbf3051458fe249aa51fdeea9c000b719f23ba (patch)
treeed25d54910b6d19b956525441dd73e697ac22619 /rtic-time
parent5bcbe92f55e2376be0717636f6d4e30227040496 (diff)
Clean up
Diffstat (limited to 'rtic-time')
-rw-r--r--rtic-time/tests/timer_queue.rs17
1 files changed, 6 insertions, 11 deletions
diff --git a/rtic-time/tests/timer_queue.rs b/rtic-time/tests/timer_queue.rs
index 7b23374..4f285e0 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<u64> 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;