1 个稳定版本
1.0.0 | 2024 年 3 月 7 日 |
---|
#225 在 日期和时间
在 bbolt-rs 中使用
31KB
482 行
单调计时器
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");
归属
此项目是https://github.com/Yoric/timer.rs的稍作修改版本。
lib.rs
:
一个简单的计时器,用于在指定时间或延迟后入队要执行的操作。