Crates.io | timer |
lib.rs | timer |
version | 0.2.0 |
source | src |
created_at | 2016-03-01 22:19:44.10565 |
updated_at | 2017-09-11 16:51:38.537899 |
description | A simple timer. Use it to schedule execution of closures after a delay or at a given timestamp. |
homepage | https://github.com/Yoric/timer.rs |
repository | |
max_upload_size | |
id | 4342 |
size | 47,036 |
Simple implementation of a Timer in and for Rust.
extern crate timer;
extern crate chrono;
use std::sync::mpsc::channel;
let timer = timer::Timer::new();
let (tx, rx) = channel();
timer.schedule_with_delay(chrono::Duration::seconds(3), move || {
tx.send(()).unwrap();
});
rx.recv().unwrap();
println!("This code has been executed after 3 seconds");