Struct wasm_timer::Timer[][src]

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:

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!

Implementations

impl Timer[src]

pub fn new() -> Timer

Notable traits for Timer

impl Future for Timer type Output = ();
[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 Debug for Timer[src]

impl Drop for Timer[src]

impl Future for Timer[src]

type Output = ()

The type of value produced on completion.

Auto Trait Implementations

impl !RefUnwindSafe for Timer

impl Send for Timer

impl Sync for Timer

impl Unpin for Timer

impl !UnwindSafe for Timer

Blanket Implementations

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

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

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

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

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

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

impl<F> IntoFuture for F where
    F: Future
[src]

type Output = <F as Future>::Output

🔬 This is a nightly-only experimental API. (into_future)

The output that the future will produce on completion.

type Future = F

🔬 This is a nightly-only experimental API. (into_future)

Which kind of future are we turning this into?

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.