Skip to content
This repository has been archived by the owner on Apr 2, 2018. It is now read-only.

how to stop the timer #28

Open
guanqun opened this issue Jul 6, 2017 · 1 comment
Open

how to stop the timer #28

guanqun opened this issue Jul 6, 2017 · 1 comment

Comments

@guanqun
Copy link

guanqun commented Jul 6, 2017

This seems to be a dumb question, but how can we stop a timer, there's no such "reset()" or "stop" interface.

My code basically looks like this:

    let mut core = ::tokio_core::reactor::Core::new().unwrap();
    let timer = Timer::default();
    let my_timer = timer.interval(std::time::Duration::from_millis(1_000))
        .for_each(|_| {
                      println!("timer triggered");
                      // how can I e.g. remove this my_timer after three triggers?
                      Ok(())
         });

    core.run(my_timer).unwarp();
@BusyJay
Copy link
Contributor

BusyJay commented Dec 13, 2017

Why not timer.interval(xx).take(3).for_each()?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants