Open spfuetzner opened 4 years ago
Oh... not good.
I don't know if I'll have time to work on this, but I'll definitely review patches!
I can take a look at this, if you want @spfuetzner
Hi everyone!
This is not a bug from timer.rs, but from the test code. When exit the scope, the timer
is drop, therefore it will cancel it.
The guard.ignore()
works by doing so:
fn main()
{
let timer = timer::Timer::new();
{
let now = chrono::offset::Local::now();
let repeat = chrono::Duration::seconds(1);
let guard = timer.schedule(now, Some(repeat), || println!("test"));
guard.ignore();
std::thread::sleep(std::time::Duration::from_secs(5));
}
std::thread::sleep(std::time::Duration::from_secs(1000));
}
Ah thought so. Maybe we should document that you can't drop the timer itself. (And will have to start it inside a new thread to daemonize)
The following code just shows "test" for the 5 seconds while the first sleep() is running. So the guards isn't actually ignored.