embassy-time: add async tick() method to Ticker
This commit is contained in:
parent
28b695e7c9
commit
4e212c7a0b
@ -3,7 +3,7 @@ use core::pin::Pin;
|
|||||||
use core::task::{Context, Poll, Waker};
|
use core::task::{Context, Poll, Waker};
|
||||||
|
|
||||||
use futures_util::future::{select, Either};
|
use futures_util::future::{select, Either};
|
||||||
use futures_util::{pin_mut, Stream};
|
use futures_util::{pin_mut, Stream, StreamExt};
|
||||||
|
|
||||||
use crate::{Duration, Instant};
|
use crate::{Duration, Instant};
|
||||||
|
|
||||||
@ -132,6 +132,11 @@ impl Ticker {
|
|||||||
let expires_at = Instant::now() + duration;
|
let expires_at = Instant::now() + duration;
|
||||||
Self { expires_at, 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 {}
|
impl Unpin for Ticker {}
|
||||||
|
Loading…
Reference in New Issue
Block a user