aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkbleeke <[email protected]>2023-02-28 17:04:56 +0100
committerkbleeke <[email protected]>2023-02-28 17:25:42 +0100
commit4e212c7a0b171cae116d9a95353a0611f424c68d (patch)
tree0705e546ca823d3d8a326bd0bf8567c0a2839ed3
parent28b695e7c9b134cafcdfb5897d26b00e396c7776 (diff)
embassy-time: add async tick() method to Ticker
-rw-r--r--embassy-time/src/timer.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/embassy-time/src/timer.rs b/embassy-time/src/timer.rs
index f74b5cb24..416830a7c 100644
--- a/embassy-time/src/timer.rs
+++ b/embassy-time/src/timer.rs
@@ -3,7 +3,7 @@ use core::pin::Pin;
3use core::task::{Context, Poll, Waker}; 3use core::task::{Context, Poll, Waker};
4 4
5use futures_util::future::{select, Either}; 5use futures_util::future::{select, Either};
6use futures_util::{pin_mut, Stream}; 6use futures_util::{pin_mut, Stream, StreamExt};
7 7
8use crate::{Duration, Instant}; 8use crate::{Duration, Instant};
9 9
@@ -132,6 +132,11 @@ impl Ticker {
132 let expires_at = Instant::now() + duration; 132 let expires_at = Instant::now() + duration;
133 Self { expires_at, duration } 133 Self { expires_at, duration }
134 } 134 }
135
136 /// Waits for the next tick
137 pub async fn next(&mut self) {
138 <Self as StreamExt>::next(self).await;
139 }
135} 140}
136 141
137impl Unpin for Ticker {} 142impl Unpin for Ticker {}