pub struct TimerWheel { /* private fields */ }Expand description
Timer wheel for efficient timer management.
Implementations§
Source§impl TimerWheel
impl TimerWheel
Sourcepub fn cancel(&mut self, timer_id: u64) -> bool
pub fn cancel(&mut self, timer_id: u64) -> bool
Cancel a timer by ID. Returns true if a live timer was cancelled.
Cancelling an id that was never scheduled or has already fired/drained is a no-op: such an id has no entry left in the heap, so recording a tombstone for it would never be reclaimed and would leak unboundedly.
Sourcepub fn poll_expired(&mut self) -> usize
pub fn poll_expired(&mut self) -> usize
Poll for expired timers and wake them.
Sourcepub fn next_expiration(&mut self) -> Option<Instant>
pub fn next_expiration(&mut self) -> Option<Instant>
Get the next expiration time.
Sourcepub fn timer_count(&self) -> usize
pub fn timer_count(&self) -> usize
Get the number of live (scheduled, not cancelled) timers.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TimerWheel
impl RefUnwindSafe for TimerWheel
impl Send for TimerWheel
impl Sync for TimerWheel
impl Unpin for TimerWheel
impl UnsafeUnpin for TimerWheel
impl UnwindSafe for TimerWheel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more