embassy-time: add async tick() method to Ticker

This commit is contained in:
kbleeke 2023-02-28 17:04:56 +01:00
parent 28b695e7c9
commit 4e212c7a0b

View File

@ -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) {
<Self as StreamExt>::next(self).await;
}
}
impl Unpin for Ticker {}