pub async fn delay(ct: &CancellationToken, duration: Duration) -> boolExpand description
Wait for duration, returning false as soon as ct is cancelled.
This is the interruptible counterpart of tokio::time::sleep: a worker that
sleeps for 30s stops within milliseconds of a shutdown.
ⓘ
while !ct.is_cancelled() {
work().await?;
if !delay(&ct, interval).await {
break; // cancelled
}
}