From: Ian Jackson Date: Sun, 22 Aug 2021 17:34:35 +0000 (+0100) Subject: early return deadlines X-Git-Tag: hippotat/1.0.0~92 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=d3ba91d74c8b1fd22ae19a0d6d9618e161ca60e4;p=hippotat.git early return deadlines Signed-off-by: Ian Jackson --- diff --git a/server/suser.rs b/server/suser.rs index 3a683a6..b1a6409 100644 --- a/server/suser.rs +++ b/server/suser.rs @@ -49,6 +49,11 @@ pub async fn run(global: Arc, .min() .unwrap_or(ic.max_batch_down) .sat(); + let earliest_deadline = outstanding + .iter() + .map(|o| o.oi.deadline) + .min(); + if let Some(req) = { let now = Instant::now(); @@ -210,6 +215,14 @@ pub async fn run(global: Arc, }, } } + + () = async {if let Some(deadline) = earliest_deadline { + tokio::time::sleep_until(deadline).await; + } else { + future::pending().await + } } => + { + } } } }