use std::time::Duration;
use set_timeout::TimeoutScheduler;
#[tokio::main]
async fn main() {
let scheduler = TimeoutScheduler::new(None);
let cancellation_token = scheduler.set_timeout(Duration::from_secs(1), async move {
panic!("cancelled timeout was ran");
});
scheduler.set_timeout(Duration::from_secs(1), async move {
println!("the task that wasn't cancelled was executed");
});
tokio::time::sleep(Duration::from_millis(990)).await;
scheduler.cancel_timeout(cancellation_token);
tokio::time::sleep(Duration::from_secs(1)).await;
}