TimerDriver

Trait TimerDriver 

Source
pub trait TimerDriver<T: Timer>: Default {
    // Required methods
    fn insert(
        &mut self,
        when: Instant,
        timer: T,
    ) -> Result<TimerHandle, InsertError<T>>;
    fn cancel(&mut self, handle: TimerHandle) -> Option<T>;
    fn poll(
        &mut self,
        now: Instant,
        ctx: &mut T::Context,
    ) -> Result<usize, PollError>;
}
Expand description

Trait for timer driver implementations.

Enables generic runtime code that works with any wheel variant.

Required Methods§

Source

fn insert( &mut self, when: Instant, timer: T, ) -> Result<TimerHandle, InsertError<T>>

Insert a timer to fire at the given instant.

Returns a handle for cancellation, or an error containing the timer if the wheel is at capacity.

Source

fn cancel(&mut self, handle: TimerHandle) -> Option<T>

Cancel a pending timer.

Returns the timer if still pending, None if already fired or invalid handle.

Source

fn poll( &mut self, now: Instant, ctx: &mut T::Context, ) -> Result<usize, PollError>

Poll the wheel, firing all timers due by now.

Returns the number of timers fired, or an error if timers were lost during rescheduling.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T, const G: usize, const R: u64, const S: usize, const P: usize> TimerDriver<T> for BitWheel<T, G, R, S, P>
where T: Timer,

Source§

impl<T, const G: usize, const R: u64, const S: usize, const P: usize, const F: u64> TimerDriver<T> for BitWheelWithFailover<T, G, R, S, P, F>
where T: Timer,

Source§

impl<T, const PG: usize, const PR: u64, const PS: usize, const OG: usize, const OR: u64, const OS: usize, const OP: usize> TimerDriver<T> for DualBitWheel<T, PG, PR, PS, OG, OR, OS, OP>
where T: Timer,