Skip to content

Commit

Permalink
Replace tokio-timer with futures-timer for higher timer resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
doyoubi committed Oct 23, 2019
1 parent 76b94b1 commit 8a8f76e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -9,7 +9,7 @@ edition = "2018"
[dependencies]
tokio = "0.1.14"
futures = "0.1.25"
tokio-timer = "0.2.8"
futures-timer = "0.1"

[build-dependencies]
skeptic = "0.13"
Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
@@ -1,11 +1,11 @@
use std::mem;
use std::io;
use std::prelude::v1::*;
use std::time::{Duration, Instant};
use std::time::Duration;

use futures::stream::{Fuse, Stream};
use futures::{Async, Future, Poll};
use tokio::timer;
use tokio::timer::Delay;
use futures_timer::Delay;

/// An adaptor that chunks up elements in a vector.
///
Expand Down Expand Up @@ -39,7 +39,7 @@ enum Kind<T> {
Inner(T),

/// Timer returned an error.
Timer(timer::Error),
Timer(io::Error),
}

impl<S> Chunks<S>
Expand Down Expand Up @@ -114,7 +114,7 @@ where
// the full one.
Ok(Async::Ready(Some(item))) => {
if self.items.is_empty() {
self.clock = Some(Delay::new(Instant::now() + self.duration));
self.clock = Some(Delay::new(self.duration));
}
self.items.push(item);
if self.items.len() >= cap {
Expand Down Expand Up @@ -236,7 +236,7 @@ mod tests {

let iter = vec![5].into_iter();
let stream1 = stream::iter_ok::<_, io::Error>(iter).and_then(|n| {
Delay::new(Instant::now() + Duration::from_millis(300))
Delay::new(Duration::from_millis(300))
.and_then(move |_| Ok(n))
.map_err(|e| io::Error::new(io::ErrorKind::TimedOut, e))
});
Expand Down

0 comments on commit 8a8f76e

Please sign in to comment.