Skip to main content

TimerWheel

Struct TimerWheel 

Source
pub struct TimerWheel<V> { /* private fields */ }

Implementations§

Source§

impl<V> TimerWheel<V>

Source

pub fn new(num_slots: usize) -> Self

num_slots rounded up to a power of two.

Source

pub fn num_slots(&self) -> usize

Source

pub fn schedule(&mut self, delay_ticks: usize, value: V) -> u64

Schedule value to fire in delay_ticks. Returns an id for cancel.

Source

pub fn cancel(&mut self, id: u64) -> bool

Mark a scheduled timer cancelled. Returns true if it was pending.

Source

pub fn tick(&mut self) -> Vec<V>

Advance the hand one tick. Returns the values of all timers that fired (rounds was 0 and not cancelled). Cancelled timers are dropped silently. Other timers have their rounds decremented.

Auto Trait Implementations§

§

impl<V> Freeze for TimerWheel<V>

§

impl<V> RefUnwindSafe for TimerWheel<V>
where V: RefUnwindSafe,

§

impl<V> Send for TimerWheel<V>
where V: Send,

§

impl<V> Sync for TimerWheel<V>
where V: Sync,

§

impl<V> Unpin for TimerWheel<V>
where V: Unpin,

§

impl<V> UnsafeUnpin for TimerWheel<V>

§

impl<V> UnwindSafe for TimerWheel<V>
where V: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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 T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.