Crates.io | naive-timer |
lib.rs | naive-timer |
version | 0.2.0 |
source | src |
created_at | 2020-06-23 16:58:07.815827 |
updated_at | 2021-08-08 06:50:02.080021 |
description | A minimal naive timer for embedded (no_std) platforms. |
homepage | https://github.com/rcore-os/naive-timer |
repository | https://github.com/rcore-os/naive-timer |
max_upload_size | |
id | 257222 |
size | 10,109 |
A minimal naive timer for embedded platforms in Rust (no_std + alloc).
let mut timer = naive_timer::Timer::default();
let event = Arc::new(AtomicBool::new(false));
// add a timer with callback
timer.add(Duration::from_secs(1), {
let event = event.clone();
move |_now| event.store(true, Ordering::SeqCst)
});
// expire timers (usually from timer interrupt)
timer.expire(Duration::from_millis(1000));
assert_eq!(event.load(Ordering::SeqCst), true);
assert_eq!(timer.next(), None);
The code in this repository is licensed under the MIT License.