Timer wheel - Rust
Single-level hashed timer wheel. O(1) schedule and cancel; tick fires every timer with rounds=0 in the current bucket.
Part of the submillisecond.com cookbook. Zero external dependencies; std only.
Install
[]
= "0.4"
Quickstart
Public API
pub struct TimerWheel<V>pub fn new(num_slots: usize) -> Selfpub fn num_slots(&self) -> usizepub fn schedule(&mut self, delay_ticks: usize, value: V) -> u64pub fn cancel(&mut self, id: u64) -> boolpub fn tick(&mut self) -> Vec<V>
Files
src/lib.rs- implementation.tests/- integration tests; correctness, edge cases, property/stress.examples/demo.rs- stdout walkthrough.examples/perf_main.rs- bench entry (behind theharnessfeature).
License
Dual-licensed under MIT OR Apache-2.0.