2 releases

0.1.1 Jan 5, 2024
0.1.0 Jan 4, 2024

#1008 in Concurrency

Download history 94/week @ 2024-12-25 202/week @ 2025-01-01 320/week @ 2025-01-08 330/week @ 2025-01-15 668/week @ 2025-01-22 344/week @ 2025-01-29 628/week @ 2025-02-05 574/week @ 2025-02-12 514/week @ 2025-02-19 554/week @ 2025-02-26 735/week @ 2025-03-05 876/week @ 2025-03-12 725/week @ 2025-03-19 684/week @ 2025-03-26 515/week @ 2025-04-02 550/week @ 2025-04-09

2,598 downloads per month
Used in 8 crates (2 directly)

Apache-2.0

48KB
603 lines

Utils using spin_sleep.

Example: Frame limiter

Interval may be used to limit a loop to a max fps by calling Interval::tick at the start or end of each loop.

// Create an interval to tick 144 times each second
let mut interval = spin_sleep_util::interval(Duration::from_secs(1) / 144);
loop {
    compute_something(); // do loop work

    // tick: sleep using a SpinSleeper until next tick.
    // The default `Skip` missed ticke behaviour is appropriate for a frame limiter
    interval.tick();
}

spin_sleep_util crates.io Documentation

Utils using spin_sleep.

Example: Frame limiter

Interval may be used to limit a loop to a max fps by calling Interval::tick at the start or end of each loop.

// Create an interval to tick 144 times each second
let mut interval = spin_sleep_util::interval(Duration::from_secs(1) / 144);
loop {
    compute_something(); // do loop work

    // tick: sleep using a SpinSleeper until next tick.
    // The default `Skip` missed ticke behaviour is appropriate for a frame limiter
    interval.tick();
}

Dependencies

~0–6.5MB
~31K SLoC