Crates.io | monotonic-timer |
lib.rs | monotonic-timer |
version | 1.0.0 |
source | src |
created_at | 2024-03-07 14:37:13.149215 |
updated_at | 2024-03-07 14:37:13.149215 |
description | A simple monotonic timer. Use it to schedule execution of closures after a delay. |
homepage | |
repository | https://github.com/ambaxter/monotonic_timer.rs.git |
max_upload_size | |
id | 1165994 |
size | 47,959 |
Simple implementation of a Monotonic Timer in and for Rust.
extern crate monotonic_timer;
use std::sync::mpsc::channel;
let timer = monotonic_timer::Timer::new();
let (tx, rx) = channel();
let _guard = timer.schedule_with_delay(Duration::from_sec(3), move || {
tx.send(()).unwrap();
});
rx.recv().unwrap();
println!("This code has been executed after 3 seconds");
This project is a slightly modified version of https://github.com/Yoric/timer.rs.