Function agera::timer::wait_until

source ·
pub async fn wait_until(deadline: Instant)
Expand description

Asynchronously waits until deadline is reached.

No work is performed while awaiting on the wait future to complete. This operates at millisecond granularity and should not be used for tasks that require high-resolution timers.

To run something regularly on a schedule, see ticker functions in this module.

The maximum duration for a wait is 68719476734 milliseconds (approximately 2.2 years).

Cancellation

Canceling a wait being awaited for via the .await operator is not possible. Use [free_timeout] for such a purpose.

Examples

Wait 100ms and print “100 ms have elapsed”.

use agera::timer::*;

async fn example_fn() {
    wait(Instant::now() + Duration::from_millis(100)).await;
    println!("100 ms have elapsed");
}