summaryrefslogtreecommitdiffstats
path: root/futures/src/time.rs
diff options
context:
space:
mode:
Diffstat (limited to 'futures/src/time.rs')
-rw-r--r--futures/src/time.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/futures/src/time.rs b/futures/src/time.rs
index 86b4a4e7..c11942d2 100644
--- a/futures/src/time.rs
+++ b/futures/src/time.rs
@@ -35,8 +35,16 @@ where
_input: futures::stream::BoxStream<'static, E>,
) -> futures::stream::BoxStream<'static, Self::Output> {
use futures::stream::StreamExt;
+ use std::time::Instant;
- smol::Timer::interval(self.0).boxed()
+ let duration = self.0;
+
+ futures::stream::unfold(Instant::now(), move |last_tick| async move {
+ let last_tick = smol::Timer::at(last_tick + duration).await;
+
+ Some((last_tick, last_tick))
+ })
+ .boxed()
}
}