pub struct Timer<RT: Access> { /* private fields */ }
Expand description

A Future that represents a timer.

If this future returns Poll::Ready(DeadlinePassed) it means that the deadline has passed. If it returns Poll::Pending it’s not yet passed.

Examples

use std::time::Duration;

use heph::actor;
use heph_rt::ThreadLocal;
use heph_rt::timer::Timer;

async fn actor(mut ctx: actor::Context<!, ThreadLocal>) {
    // Create a timer, this will be ready once the timeout has passed.
    let timeout = Timer::after(&mut ctx, Duration::from_millis(200));

    // Wait for the timer to pass.
    timeout.await;
    println!("200 milliseconds have passed!");
}

Implementations

Create a new Timer.

Create a new timer, based on a timeout.

Same as calling Timer::at(&mut ctx, Instant::now() + timeout).

Returns the deadline set for this Timer.

Returns true if the deadline has passed.

Wrap a future creating a new Deadline.

Trait Implementations

Error type used in bind_to. Read more
Bind a type to the Actor that owns the ctx. Read more
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.

Calls U::from(self).

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

The output that the future will produce on completion.
Which kind of future are we turning this into?
Creates a future from a value. Read more
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.