embassy-time: Introduced reset function for Ticker

This commit is contained in:
Frostie314159 2023-08-29 08:29:38 +02:00
parent 0568738f77
commit 70662ec4ba
No known key found for this signature in database
GPG Key ID: 0C2C22C244C8223F

View File

@ -133,7 +133,14 @@ impl Ticker {
Self { expires_at, duration }
}
/// Waits for the next tick
/// Resets the ticker back to its original state.
///
/// This causes the ticker to go back to zero, even if the current tick isn't over yet.
pub fn reset(&mut self) {
self.expires_at = Instant::now() + self.duration;
}
/// Waits for the next tick.
pub fn next(&mut self) -> impl Future<Output = ()> + '_ {
poll_fn(|cx| {
if self.expires_at <= Instant::now() {