pub(crate) async fn sleep_until_or_deadline(duration: Duration, deadline: Option<Instant>) -> bool {
    let wakeup = Instant::now() + duration;
    if let Some(deadline) = deadline {
        // If we would exceed the deadline, don't wait at all
        if deadline < wakeup {
            return false;
        }
    }
    tokio::time::sleep_until(wakeup).await;
    true
}
/// Sleep for a given duration, or until a given deadline expires, returning `true` if the sleep
/// completed before the deadline, or `false` if it did not.
///
/// This short-circuits and immediately returns `false` if it would exceed the deadline.
Sleep for a given duration, or until a given deadline expires, returning `true` if the sleep
completed before the deadline, or `false` if it did not.

This short-circuits and immediately returns `false` if it would exceed the deadline.
Sleep for a given duration or until a given deadline expires returning ` true ` if the sleep completed before the deadline or ` false ` if it did not . This short - circuits and immediately returns ` false ` if it would exceed the deadline .
pub(crate) async fn sleep_until_or_deadline(duration: Duration, deadline: Option<Instant>) -> bool {
    let wakeup = Instant::now() + duration;
    if let Some(deadline) = deadline {
        // If we would exceed the deadline, don't wait at all
        if deadline < wakeup {
            return false;
        }
    }
    tokio::time::sleep_until(wakeup).await;
    true
}
pub ( crate ) async fn sleep_until_or_deadline ( duration : Duration , deadline : Option < Instant > ) -> bool { let wakeup = Instant :: now ( ) + duration ; if let Some ( deadline ) = deadline { // If we would exceed the deadline, don't wait at all if deadline < wakeup { return false ; } } tokio :: time :: sleep_until ( wakeup ) . await ; true }
Sleep for a given duration, or until a given deadline expires, returning `true` if the sleep
completed before the deadline, or `false` if it did not.
Sleep for a given duration or until a given deadline expires returning ` true ` if the sleep completed before the deadline or ` false ` if it did not .
duration
Duration
deadline
Option<Instant>