Skip to content
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
@jedisct1

Description

@jedisct1

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions