diff options
| author | kbleeke <[email protected]> | 2023-02-28 17:04:56 +0100 |
|---|---|---|
| committer | kbleeke <[email protected]> | 2023-02-28 17:25:42 +0100 |
| commit | 4e212c7a0b171cae116d9a95353a0611f424c68d (patch) | |
| tree | 0705e546ca823d3d8a326bd0bf8567c0a2839ed3 /embassy-time | |
| parent | 28b695e7c9b134cafcdfb5897d26b00e396c7776 (diff) | |
embassy-time: add async tick() method to Ticker
Diffstat (limited to 'embassy-time')
| -rw-r--r-- | embassy-time/src/timer.rs | 7 |
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; | |||
| 3 | use core::task::{Context, Poll, Waker}; | 3 | use core::task::{Context, Poll, Waker}; |
| 4 | 4 | ||
| 5 | use futures_util::future::{select, Either}; | 5 | use futures_util::future::{select, Either}; |
| 6 | use futures_util::{pin_mut, Stream}; | 6 | use futures_util::{pin_mut, Stream, StreamExt}; |
| 7 | 7 | ||
| 8 | use crate::{Duration, Instant}; | 8 | use 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 | ||
| 137 | impl Unpin for Ticker {} | 142 | impl Unpin for Ticker {} |
