#计时器 #计划 #chrono #闹钟 #计时器

monotonic-timer

一个简单的单调计时器。使用它来在延迟后安排闭包的执行。

1 个稳定版本

1.0.0 2024 年 3 月 7 日

#225日期和时间


bbolt-rs 中使用

MPL-2.0 许可证

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:

一个简单的计时器,用于在指定时间或延迟后入队要执行的操作。

无运行时依赖