From 9c229f46f9d6c4b5b86c701cc4e7de61c603d1af Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Wed, 4 Aug 2021 00:46:25 +0100 Subject: [PATCH] prep for moving lock into reporter Signed-off-by: Ian Jackson --- src/bin/client.rs | 8 ++++---- src/reporter.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bin/client.rs b/src/bin/client.rs index 95d4730..dda2c7c 100644 --- a/src/bin/client.rs +++ b/src/bin/client.rs @@ -16,7 +16,7 @@ trait HCC: hyper::client::connect::Connect + Clone + Send + Sync + 'static { } struct ClientContext<'c,C> { ic: &'c InstanceConfig, hclient: &'c Arc>, - reporter: &'c parking_lot::Mutex>, + reporter: &'c Reporter<'c>, } #[throws(AE)] @@ -135,7 +135,7 @@ fn submit_request<'r, 'c:'r, C:HCC>( Ok::<_,AE>(resp) }).await? }.await; - let r = c.reporter.lock().report(Some(req_num), r); + let r = c.reporter.report(Some(req_num), r); if r.is_none() { tokio::time::sleep(c.ic.http_retry).await; @@ -155,7 +155,7 @@ async fn run_client( { debug!("{}: config: {:?}", &ic, &ic); - let reporter = parking_lot::Mutex::new(Reporter::new(&ic)); + let reporter = Reporter::new(&ic); let c = ClientContext { reporter: &reporter, @@ -239,7 +239,7 @@ async fn run_client( }, _ = async { }, - if reporter.lock().report(None, { + if reporter.report(None, { if rx_queue.remaining() < ic.max_batch_down.sat() * 3 /* xxx */ { // xxx make this separate option ? docs say server only Ok(()) diff --git a/src/reporter.rs b/src/reporter.rs index 04a8e49..17df050 100644 --- a/src/reporter.rs +++ b/src/reporter.rs @@ -13,7 +13,7 @@ impl<'r> Reporter<'r> { ic } } - pub fn report(&mut self, req_num: Option, r: Result) + pub fn report(&self, req_num: Option, r: Result) -> Option { match r { Ok(t) => { -- 2.30.2