-
Notifications
You must be signed in to change notification settings - Fork 659
Closed
Description
Hi, I tried to tokio_timer::Interval
with the compat layer of Futures 3.0. It seems like it produces ticks very fast, no matter which duration I give.
Example code:
use std::time::{Duration, Instant};
use futures::future;
use futures::stream::StreamExt;
use futures::executor::LocalPool;
use tokio_timer::Interval;
use futures_util::compat::{Stream01CompatExt};
fn main() {
let mut local_pool = LocalPool::new();
let dur = Duration::new(1,0);
let interval = Interval::new(Instant::now(), dur)
.compat()
.map(|_| ());
let my_fut = interval.for_each(|_| {
println!("Interval tick!");
future::ready(())
});
local_pool.run_until(my_fut);
}
Expected behaviour: "Interval tick!" will be printed about every second.
Observed behaviour: "Interval tick!" is printed very quickly. Changing the numbers given to Duration::new()
does not seem to change the behaviour.
My Cargo.toml:
[package]
name = "check_interval_compat"
version = "0.1.0"
authors = ["real"]
edition = "2018"
[dependencies]
futures-preview = { git = "https://github.com/rust-lang-nursery/futures-rs", rev = "a25e51e" }
futures-util-preview = { git = "https://github.com/rust-lang-nursery/futures-rs", rev = "a25e51e", features = ["compat"] }
tokio-timer = "0.2.7"
rustc version:
$ rustc --version
rustc 1.31.0-nightly (5af0bb830 2018-10-10)
Your work on Futures is highly appreciated!
Thank you for your help!
Metadata
Metadata
Assignees
Labels
No labels