tokio-timer
tokio-timer copied to clipboard
how to stop the timer
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();
Why not timer.interval(xx).take(3).for_each()
?