naive-timer 0.2.0

A minimal naive timer for embedded (no_std) platforms.
Documentation
  • Coverage
  • 100%
    5 out of 5 items documented1 out of 5 items with examples
  • Size
  • Source code size: 9.73 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 830.49 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 8s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • rcore-os/naive-timer
    6 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • wangrunji0408

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.