From 4e212c7a0b171cae116d9a95353a0611f424c68d Mon Sep 17 00:00:00 2001 From: kbleeke Date: Tue, 28 Feb 2023 17:04:56 +0100 Subject: [PATCH] embassy-time: add async tick() method to Ticker --- embassy-time/src/timer.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/embassy-time/src/timer.rs b/embassy-time/src/timer.rs index f74b5cb2..416830a7 100644 --- a/embassy-time/src/timer.rs +++ b/embassy-time/src/timer.rs @@ -3,7 +3,7 @@ use core::pin::Pin; use core::task::{Context, Poll, Waker}; use futures_util::future::{select, Either}; -use futures_util::{pin_mut, Stream}; +use futures_util::{pin_mut, Stream, StreamExt}; use crate::{Duration, Instant}; @@ -132,6 +132,11 @@ impl Ticker { let expires_at = Instant::now() + duration; Self { expires_at, duration } } + + /// Waits for the next tick + pub async fn next(&mut self) { + ::next(self).await; + } } impl Unpin for Ticker {}