#timer

no-std naive-timer

A minimal naive timer for embedded (no_std) platforms

2 unstable releases

0.2.0 Aug 8, 2021
0.1.0 Jun 23, 2020

#395 in No standard library

Download history 17331/week @ 2023-10-25 17535/week @ 2023-11-01 10170/week @ 2023-11-08 10510/week @ 2023-11-15 10017/week @ 2023-11-22 12903/week @ 2023-11-29 12230/week @ 2023-12-06 9999/week @ 2023-12-13 11226/week @ 2023-12-20 8102/week @ 2023-12-27 13437/week @ 2024-01-03 12641/week @ 2024-01-10 15625/week @ 2024-01-17 14945/week @ 2024-01-24 15378/week @ 2024-01-31 8915/week @ 2024-02-07

57,409 downloads per month
Used in 14 crates (via madsim)

MIT license

7KB
58 lines

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.

No runtime deps