Remove unused timer module

This commit is contained in:
Nathan Sobo 2021-04-15 20:28:10 -06:00
parent 3fa4e5acee
commit 0caf908c78
2 changed files with 0 additions and 43 deletions

View File

@ -9,7 +9,6 @@ mod sum_tree;
mod test;
mod throttle;
mod time;
mod timer;
mod util;
pub mod watch;
pub mod workspace;

View File

@ -1,42 +0,0 @@
use smol::prelude::*;
use std::{
pin::Pin,
task::Poll,
time::{Duration, Instant},
};
pub struct Repeat {
timer: smol::Timer,
period: Duration,
}
impl Stream for Repeat {
type Item = Instant;
fn poll_next(
mut self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> Poll<Option<Self::Item>> {
match self.as_mut().timer().poll(cx) {
Poll::Ready(instant) => {
let period = self.as_ref().period;
self.as_mut().timer().set_after(period);
Poll::Ready(Some(instant))
}
Poll::Pending => Poll::Pending,
}
}
}
impl Repeat {
fn timer(self: std::pin::Pin<&mut Self>) -> Pin<&mut smol::Timer> {
unsafe { self.map_unchecked_mut(|s| &mut s.timer) }
}
}
pub fn repeat(period: Duration) -> Repeat {
Repeat {
timer: smol::Timer::after(period),
period,
}
}