Struct heph::timer::Timer[][src]

pub struct Timer<RT: Access> { /* fields omitted */ }
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::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.

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

Performs the conversion.

Performs the conversion.

🔬 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.