diff options
author | 2024-04-16 20:22:57 +0200 | |
---|---|---|
committer | 2024-04-16 20:22:57 +0200 | |
commit | e8ec6b94b68801ce4e95ada7c311320469f92a96 (patch) | |
tree | 69e2923d1c02761dc8f6a932ac1a45d955c4ebbb /futures | |
parent | 105b8bd5ad6ade1f203a0d8b0b93bd06f61f621a (diff) | |
download | iced-e8ec6b94b68801ce4e95ada7c311320469f92a96.tar.gz iced-e8ec6b94b68801ce4e95ada7c311320469f92a96.tar.bz2 iced-e8ec6b94b68801ce4e95ada7c311320469f92a96.zip |
Use `Skip` as the `MissedTickBehavior` for `tokio` futures backend
Diffstat (limited to 'futures')
-rw-r--r-- | futures/src/backend/native/tokio.rs | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/futures/src/backend/native/tokio.rs b/futures/src/backend/native/tokio.rs index 3ab7f675..df91d798 100644 --- a/futures/src/backend/native/tokio.rs +++ b/futures/src/backend/native/tokio.rs @@ -55,13 +55,15 @@ pub mod time { let start = tokio::time::Instant::now() + self.0; + let mut interval = tokio::time::interval_at(start, self.0); + interval.set_missed_tick_behavior( + tokio::time::MissedTickBehavior::Skip, + ); + let stream = { - futures::stream::unfold( - tokio::time::interval_at(start, self.0), - |mut interval| async move { - Some((interval.tick().await, interval)) - }, - ) + futures::stream::unfold(interval, |mut interval| async move { + Some((interval.tick().await, interval)) + }) }; stream.map(tokio::time::Instant::into_std).boxed() |