Skip to content

Commit

Permalink
Use smol::Timer::interval for time::Every
Browse files Browse the repository at this point in the history
  • Loading branch information
hecrj committed Jan 15, 2021
1 parent 803cc88 commit 9da0a3d
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions futures/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand Down

0 comments on commit 9da0a3d

Please sign in to comment.