naive-timer

Crates.ionaive-timer
lib.rsnaive-timer
version0.2.0
sourcesrc
created_at2020-06-23 16:58:07.815827
updated_at2021-08-08 06:50:02.080021
descriptionA minimal naive timer for embedded (no_std) platforms.
homepagehttps://github.com/rcore-os/naive-timer
repositoryhttps://github.com/rcore-os/naive-timer
max_upload_size
id257222
size10,109
Runji Wang (wangrunji0408)

documentation

https://docs.rs/naive-timer

README

naive-timer

Crate Docs Actions Status Coverage Status

A minimal naive timer for embedded platforms in Rust (no_std + alloc).

Example

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);

License

The code in this repository is licensed under the MIT License.

Commit count: 11

cargo fmt