pub struct WheelBuilder { /* private fields */ }Expand description
Builder for configuring a timer wheel.
Defaults match the Linux kernel timer wheel (1ms tick, 64 slots/level, 8x multiplier, 7 levels → ~4.7 hour range).
§Examples
use std::time::{Duration, Instant};
use nexus_timer::{Wheel, WheelBuilder};
let now = Instant::now();
// All defaults
let wheel: Wheel<u64> = WheelBuilder::default().unbounded(4096).build(now);
// Custom config
let wheel: Wheel<u64> = WheelBuilder::default()
.tick_duration(Duration::from_micros(100))
.slots_per_level(32)
.unbounded(4096)
.build(now);Implementations§
Source§impl WheelBuilder
impl WheelBuilder
Sourcepub fn tick_duration(self, d: Duration) -> Self
pub fn tick_duration(self, d: Duration) -> Self
Sets the tick duration. Default: 1ms.
Sourcepub fn slots_per_level(self, n: usize) -> Self
pub fn slots_per_level(self, n: usize) -> Self
Sets the number of slots per level. Must be a power of 2. Default: 64.
Sourcepub fn clk_shift(self, s: u32) -> Self
pub fn clk_shift(self, s: u32) -> Self
Sets the bit shift between levels (multiplier = 2^clk_shift). Default: 3 (8x).
Sourcepub fn num_levels(self, n: usize) -> Self
pub fn num_levels(self, n: usize) -> Self
Sets the number of levels. Default: 7.
Sourcepub fn unbounded(self, chunk_capacity: usize) -> UnboundedWheelBuilder
pub fn unbounded(self, chunk_capacity: usize) -> UnboundedWheelBuilder
Transitions to an unbounded wheel builder.
chunk_capacity is the slab chunk size (entries per chunk). The slab
grows by adding new chunks as needed.
Sourcepub fn bounded(self, capacity: usize) -> BoundedWheelBuilder
pub fn bounded(self, capacity: usize) -> BoundedWheelBuilder
Transitions to a bounded wheel builder.
capacity is the maximum number of concurrent timers.
Trait Implementations§
Source§impl Clone for WheelBuilder
impl Clone for WheelBuilder
Source§fn clone(&self) -> WheelBuilder
fn clone(&self) -> WheelBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for WheelBuilder
impl Debug for WheelBuilder
Source§impl Default for WheelBuilder
impl Default for WheelBuilder
impl Copy for WheelBuilder
Auto Trait Implementations§
impl Freeze for WheelBuilder
impl RefUnwindSafe for WheelBuilder
impl Send for WheelBuilder
impl Sync for WheelBuilder
impl Unpin for WheelBuilder
impl UnsafeUnpin for WheelBuilder
impl UnwindSafe for WheelBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more