Skip to main content

TimerProvider

Trait TimerProvider 

Source
pub trait TimerProvider {
    // Required methods
    fn schedule(&mut self, id: u64, delay_ms: u32) -> Result<u64, TimerError>;
    fn cancel(&mut self, id: u64) -> Result<bool, TimerError>;
    fn poll_expired(
        &mut self,
        output: &mut Vec<TimerWakeup>,
    ) -> Result<(), TimerError>;
    fn wait_expired(&mut self) -> Result<Option<TimerWakeup>, TimerError>;
    fn has_pending(&self) -> bool;
}
Expand description

A host capability that schedules real time without observing machine state.

The provider owns only opaque u64 identifiers and monotonic millisecond deadlines; it never stores a JavaScript Value. The machine owns visible ordering and every callback identity.

Required Methods§

Source

fn schedule(&mut self, id: u64, delay_ms: u32) -> Result<u64, TimerError>

Arms a timer for id after at least delay_ms milliseconds, returning the provider-monotonic absolute-millisecond deadline.

Source

fn cancel(&mut self, id: u64) -> Result<bool, TimerError>

Cancels the armed timer for id, returning whether one was removed.

Source

fn poll_expired( &mut self, output: &mut Vec<TimerWakeup>, ) -> Result<(), TimerError>

Drains every currently expired timer into output without blocking.

Source

fn wait_expired(&mut self) -> Result<Option<TimerWakeup>, TimerError>

Blocks until the next timer expires, or returns None when none pend.

Source

fn has_pending(&self) -> bool

Reports whether the provider has any armed timer.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§