From: Ian Jackson Date: Sun, 15 Aug 2021 23:08:02 +0000 (+0100) Subject: server: Break out OutstandingInner X-Git-Tag: hippotat/1.0.0~157 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?p=hippotat.git;a=commitdiff_plain;h=6e9d9ba4189d5b65327c6baba8f409d4a0fdf3e9 server: Break out OutstandingInner Signed-off-by: Ian Jackson --- diff --git a/src/bin/server.rs b/src/bin/server.rs index 65b7e48..cf0eec1 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -224,6 +224,10 @@ async fn run_client(ic: Arc, { struct Outstanding { reply_to: tokio::sync::oneshot::Sender, + oi: OutstandingInner, + } + #[derive(Debug)] + struct OutstandingInner { target_requests_outstanding: u32, } let mut outstanding: VecDeque = default(); @@ -242,7 +246,7 @@ async fn run_client(ic: Arc, if ! downbound.is_empty() { outstanding.pop_front() } else if let Some((i,_)) = outstanding.iter().enumerate().find({ - |(_,o)| outstanding.len() > o.target_requests_outstanding.sat() + |(_,o)| outstanding.len() > o.oi.target_requests_outstanding.sat() }) { Some(outstanding.remove(i).unwrap()) } else { @@ -332,14 +336,12 @@ async fn run_client(ic: Arc, dbg!(comp.name, DumpHex(comp.payload)); } - Ok::<_,AE>(target_requests_outstanding) + let oi = OutstandingInner { + target_requests_outstanding, + }; + Ok::<_,AE>(oi) }.await { - Ok(target_requests_outstanding) => { - outstanding.push_back(Outstanding { - reply_to, - target_requests_outstanding, - }); - }, + Ok(oi) => outstanding.push_back(Outstanding { reply_to, oi }), Err(e) => { try_send_response(reply_to, WebResponse { data: Err(e),