pub struct QuadWheelWithOverflow<EntryType>where
EntryType: Debug,{ /* private fields */ }
Expand description
An implementation of four-level byte-sized wheel
Any value scheduled so far off that it doesn’t fit into the wheel
is stored in an overflow Vec
and added to the wheel, once time as advanced enough
that it actually fits.
In this design the maximum schedule duration for the wheel itself is u32::MAX
units (typically ms),
everything else goes into the overflow Vec
.
Implementations§
source§impl<EntryType> QuadWheelWithOverflow<EntryType>where
EntryType: TimerEntryWithDelay,
impl<EntryType> QuadWheelWithOverflow<EntryType>where EntryType: TimerEntryWithDelay,
sourcepub fn insert(&mut self, e: EntryType) -> Result<(), TimerError<EntryType>>
pub fn insert(&mut self, e: EntryType) -> Result<(), TimerError<EntryType>>
Insert a new timeout into the wheel
source§impl<EntryType> QuadWheelWithOverflow<EntryType>where
EntryType: Debug,
impl<EntryType> QuadWheelWithOverflow<EntryType>where EntryType: Debug,
sourcepub fn new(pruner: fn(_: &EntryType) -> PruneDecision) -> Self
pub fn new(pruner: fn(_: &EntryType) -> PruneDecision) -> Self
Create a new wheel
sourcepub fn remaining_time_in_cycle(&self) -> u64
pub fn remaining_time_in_cycle(&self) -> u64
Described how many ticks are left before the timer has wrapped around completely
sourcepub fn current_time_in_cycle(&self) -> u32
pub fn current_time_in_cycle(&self) -> u32
Produces a 32-bit timestamp including the current index of every wheel
sourcepub fn insert_with_delay(
&mut self,
e: EntryType,
delay: Duration
) -> Result<(), TimerError<EntryType>>
pub fn insert_with_delay( &mut self, e: EntryType, delay: Duration ) -> Result<(), TimerError<EntryType>>
Insert a new timeout into the wheel to be returned after delay
ticks
sourcepub fn tick(&mut self) -> Vec<EntryType>
pub fn tick(&mut self) -> Vec<EntryType>
Move the wheel forward by a single unit (ms)
Returns a list of all timers that expire during this tick.