subms-timer-wheel 0.5.2

submillisecond.com cookbook recipe - concurrency: subms-timer-wheel. Single-level hashed timer wheel with O(1) schedule and cancel.
Documentation
  • Coverage
  • 71.43%
    5 out of 7 items documented1 out of 7 items with examples
  • Size
  • Source code size: 69.35 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 299.86 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 4s Average build duration of successful builds.
  • all releases: 4s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • kdog007

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

[dependencies]
subms-timer-wheel = "0.4"

Quickstart

cargo test --release
cargo run --example demo

Public API

  • pub struct TimerWheel<V>
  • pub fn new(num_slots: usize) -> Self
  • pub fn num_slots(&self) -> usize
  • pub fn schedule(&mut self, delay_ticks: usize, value: V) -> u64
  • pub fn cancel(&mut self, id: u64) -> bool
  • pub 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 the harness feature).

License

Dual-licensed under MIT OR Apache-2.0.