Use Skip as the MissedTickBehavior for tokio futures backend

This commit is contained in:
Héctor Ramón Jiménez 2024-04-16 20:22:57 +02:00
parent 105b8bd5ad
commit e8ec6b94b6
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -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()