pub struct TimerQueue { /* private fields */ }Expand description
Timer queue managing a set of timers using a BinaryHeap.
Timers are ordered by their fire_date for efficient expiration checking. Repeating timers are automatically rearmed after firing.
Implementations§
Source§impl TimerQueue
impl TimerQueue
Sourcepub fn reschedule(&mut self, timer_id: TimerId)
pub fn reschedule(&mut self, timer_id: TimerId)
Sourcepub fn invalidate(&mut self, timer_id: TimerId)
pub fn invalidate(&mut self, timer_id: TimerId)
Sourcepub fn fire_expired(&mut self) -> Vec<(TimerId, bool)>
pub fn fire_expired(&mut self) -> Vec<(TimerId, bool)>
Fire all expired timers
Returns a list of (timer_id, autoclose) for timers that fired
Sourcepub fn nextfire_delay(&self) -> Option<f64>
pub fn nextfire_delay(&self) -> Option<f64>
Get the time until the next timer fires
Returns None if no timers are armed
Sourcepub fn add_timer(&mut self, timer: EngineBaseTimer) -> TimerId
pub fn add_timer(&mut self, timer: EngineBaseTimer) -> TimerId
Add a timer to the queue
Returns the TimerId for the new timer
Sourcepub fn remove_timer(&mut self, timer_id: TimerId)
pub fn remove_timer(&mut self, timer_id: TimerId)
Remove a timer by ID
Sourcepub fn armed_count(&self) -> usize
pub fn armed_count(&self) -> usize
Get the number of armed timers
Sourcepub fn update_time(&mut self, time: f64)
pub fn update_time(&mut self, time: f64)
Update the current time (should be called before fire_expired)
Trait Implementations§
Source§impl Debug for TimerQueue
impl Debug for TimerQueue
Auto Trait Implementations§
impl Freeze for TimerQueue
impl RefUnwindSafe for TimerQueue
impl Send for TimerQueue
impl Sync for TimerQueue
impl Unpin for TimerQueue
impl UnsafeUnpin for TimerQueue
impl UnwindSafe for TimerQueue
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