Struct QuadWheelWithOverflow
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§
§impl<EntryType> QuadWheelWithOverflow<EntryType>where
EntryType: TimerEntryWithDelay,
impl<EntryType> QuadWheelWithOverflow<EntryType>where
EntryType: TimerEntryWithDelay,
pub 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
§impl<EntryType> QuadWheelWithOverflow<EntryType>where
EntryType: Debug,
impl<EntryType> QuadWheelWithOverflow<EntryType>where
EntryType: Debug,
pub fn new(
pruner: fn(_: &EntryType) -> PruneDecision,
) -> QuadWheelWithOverflow<EntryType>
pub fn new( pruner: fn(_: &EntryType) -> PruneDecision, ) -> QuadWheelWithOverflow<EntryType>
Create a new wheel
pub 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
pub 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
pub 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
pub 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.
pub fn skip(&mut self, amount: u32)
pub fn skip(&mut self, amount: u32)
Skip a certain amount
of units (ms)
No timers will be executed for the skipped time. Only use this after determining that it’s actually valid with can_skip!
pub fn can_skip(&self) -> Skip
pub fn can_skip(&self) -> Skip
Determine if and how many ticks can be skipped