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,

source

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,

source

pub fn new(pruner: fn(_: &EntryType) -> PruneDecision) -> Self

Create a new wheel

source

pub fn remaining_time_in_cycle(&self) -> u64

Described how many ticks are left before the timer has wrapped around completely

source

pub fn current_time_in_cycle(&self) -> u32

Produces a 32-bit timestamp including the current index of every wheel

source

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

source

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.

source

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!

source

pub fn can_skip(&self) -> Skip

Determine if and how many ticks can be skipped

Trait Implementations§

source§

impl<EntryType> Default for QuadWheelWithOverflow<EntryType>where EntryType: Debug,

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<EntryType> RefUnwindSafe for QuadWheelWithOverflow<EntryType>where EntryType: RefUnwindSafe,

§

impl<EntryType> Send for QuadWheelWithOverflow<EntryType>where EntryType: Send,

§

impl<EntryType> Sync for QuadWheelWithOverflow<EntryType>where EntryType: Sync,

§

impl<EntryType> Unpin for QuadWheelWithOverflow<EntryType>where EntryType: Unpin,

§

impl<EntryType> UnwindSafe for QuadWheelWithOverflow<EntryType>where EntryType: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.