[][src]Struct wasm_timer::Timer

pub struct Timer { /* fields omitted */ }

A "timer heap" used to power separately owned instances of Delay and Interval.

This timer is implemented as a priority queued-based heap. Each Timer contains a few primary methods which which to drive it:

  • next_wake indicates how long the ambient system needs to sleep until it invokes further processing on a Timer
  • advance_to is what actually fires timers on the Timer, and should be called essentially every iteration of the event loop, or when the time specified by next_wake has elapsed.
  • The Future implementation for Timer is used to process incoming timer updates and requests. This is used to schedule new timeouts, update existing ones, or delete existing timeouts. The Future implementation will never resolve, but it'll schedule notifications of when to wake up and process more messages.

Note that if you're using this crate you probably don't need to use a Timer as there is a global one already available for you run on a helper thread. If this isn't desirable, though, then the TimerHandle::set_fallback method can be used instead!

Methods

impl Timer[src]

Important traits for Timer
pub fn new() -> Timer[src]

Creates a new timer heap ready to create new timers.

pub fn handle(&self) -> TimerHandle[src]

Returns a handle to this timer heap, used to create new timeouts.

pub fn next_event(&self) -> Option<Instant>[src]

Returns the time at which this timer next needs to be invoked with advance_to.

Event loops or threads typically want to sleep until the specified instant.

pub fn advance(&mut self)[src]

Proces any timers which are supposed to fire at or before the current instant.

This method is equivalent to self.advance_to(Instant::now()).

pub fn advance_to(&mut self, now: Instant)[src]

Proces any timers which are supposed to fire before now specified.

This method should be called on Timer periodically to advance the internal state and process any pending timers which need to fire.

Trait Implementations

impl Drop for Timer[src]

impl Debug for Timer[src]

impl Future for Timer[src]

type Output = ()

The type of value produced on completion.

Auto Trait Implementations

impl Send for Timer

impl Sync for Timer

impl Unpin for Timer

impl !UnwindSafe for Timer

impl !RefUnwindSafe for Timer

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> FutureExt for T where
    T: Future + ?Sized
[src]