Use smol::Timer::interval
for time::Every
This commit is contained in:
parent
803cc88483
commit
9da0a3de54
@ -35,16 +35,8 @@ where
|
||||
_input: futures::stream::BoxStream<'static, E>,
|
||||
) -> futures::stream::BoxStream<'static, Self::Output> {
|
||||
use futures::stream::StreamExt;
|
||||
use std::time::Instant;
|
||||
|
||||
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()
|
||||
smol::Timer::interval(self.0).boxed()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user