Struct async_timer::Interval[][src]

pub struct Interval<T = PlatformTimer> {
    pub interval: Duration,
    // some fields omitted
}
Expand description

Periodic Timer

On each completion, underlying timer is restarted and therefore Future can be polled once more.

Usage

async fn job() {
}

async fn do_a_while() {
    let mut times: u8 = 0;
    let mut interval = async_timer::Interval::platform_new(core::time::Duration::from_secs(1));

    while times < 5 {
        job().await;
        interval.wait().await;
        times += 1;
    }
}

Fields

interval: Duration

Timer interval, change to this value will be reflected on next restart of timer.

Implementations

Creates new instance using platform timer

Creates new instance with specified timer type.

Stops interval

Restarts interval

Returns future for next expiration.

Trait Implementations

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.

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.