Skip to main content

TimerQueue

Struct TimerQueue 

Source
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

Source

pub fn new() -> Self

Create a new empty TimerQueue

Source

pub fn schedule(&mut self, timer_id: TimerId)

Schedule a timer for future firing

§Arguments
  • timer_id - The ID of the timer to schedule
Source

pub fn reschedule(&mut self, timer_id: TimerId)

Reschedule an existing timer

§Arguments
  • timer_id - The ID of the timer to reschedule
Source

pub fn invalidate(&mut self, timer_id: TimerId)

Invalidate (disarm) a timer

§Arguments
  • timer_id - The ID of the timer to invalidate
Source

pub fn fire_expired(&mut self) -> Vec<(TimerId, bool)>

Fire all expired timers

Returns a list of (timer_id, autoclose) for timers that fired

Source

pub fn nextfire_delay(&self) -> Option<f64>

Get the time until the next timer fires

Returns None if no timers are armed

Source

pub fn clear(&mut self)

Clear all timers

Source

pub fn add_timer(&mut self, timer: EngineBaseTimer) -> TimerId

Add a timer to the queue

Returns the TimerId for the new timer

Source

pub fn remove_timer(&mut self, timer_id: TimerId)

Remove a timer by ID

Source

pub fn armed_count(&self) -> usize

Get the number of armed timers

Source

pub fn update_time(&mut self, time: f64)

Update the current time (should be called before fire_expired)

Source

pub fn is_valid(&self, timer_id: TimerId) -> bool

Check if a timer is valid

Trait Implementations§

Source§

impl Debug for TimerQueue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TimerQueue

Source§

fn default() -> Self

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

Auto Trait Implementations§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.