This repository was archived by the owner on Apr 2, 2018. It is now read-only.
This repository was archived by the owner on Apr 2, 2018. It is now read-only.
Cannot call poll once value is consumed #36
Open
Description
Hi Carl,
Nested timers combined with futures-await lead to a panic with the above message:
#![feature(proc_macro, conservative_impl_trait, generators)]
extern crate futures_await as futures;
extern crate tokio_core;
extern crate tokio_timer;
use std::time::Duration;
use tokio_core::reactor::Core;
use futures::prelude::*;
#[async]
fn ola(lv: u32) -> Result<u32, String> {
let wheel = tokio_timer::wheel().build();
let timer = wheel.sleep(Duration::new(5, 0));
let _ = await!(timer);
println!("ola");
Ok(lv)
}
#[async]
fn grr() -> Result<u32, ()> {
let wheel = tokio_timer::wheel().build();
let ft = ola(42).map_err(|_| ());
let timer = wheel.timeout(ft, Duration::new(10, 0));
await!(timer)
}
fn main() {
let mut core = Core::new().unwrap();
core.run(grr()).unwrap();
}
thread 'main' panicked at 'cannot call poll once value is consumed'
(fired from await!(timer) in the grr() function).
Just swapping two lines, i.e. replacing:
let wheel = tokio_timer::wheel().build();
let ft = ola(42).map_err(|_| ());
let timer = wheel.timeout(ft, Duration::new(10, 0));
with
let ft = ola(42).map_err(|_| ());
let wheel = tokio_timer::wheel().build();
let timer = wheel.timeout(ft, Duration::new(10, 0));
makes the panic go awayand the executable work as expected.
Any idea why? Alex Crichton suspects a bug in tokio-timer.
Metadata
Metadata
Assignees
Labels
No labels