pub struct Timer { /* private fields */ }
Expand description

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!

Implementations

Creates a new timer heap ready to create new timers.

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

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.

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

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

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

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

The type of value produced on completion.

Attempt to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Map this future’s output to a different type, returning a new future of the resulting type. Read more

Map this future’s output to a different type, returning a new future of the resulting type. Read more

Chain on a computation for when a future finished, passing the result of the future to the provided closure f. Read more

Wrap this future in an Either future, making it the left-hand variant of that Either. Read more

Wrap this future in an Either future, making it the right-hand variant of that Either. Read more

Convert this future into a single element stream. Read more

Flatten the execution of this future when the output of this future is itself another future. Read more

Flatten the execution of this future when the successful result of this future is a stream. Read more

Fuse a future such that poll will never again be called once it has completed. This method can be used to turn any Future into a FusedFuture. Read more

Do something with the output of a future before passing it on. Read more

Catches unwinding panics while polling the future. Read more

Create a cloneable handle to this future where all handles will resolve to the same result. Read more

Turn this future into a future that yields () on completion and sends its output to another future on a separate task. Read more

Wrap the future in a Box, pinning it. Read more

Wrap the future in a Box, pinning it. Read more

A convenience for calling Future::poll on Unpin future types.

Evaluates and consumes the future, returning the resulting output if the future is ready after the first call to Future::poll. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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

The output that the future will produce on completion.

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

Which kind of future are we turning this into?

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

Creates a future from a value.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.