From 66c81605fc76ffe16667c0513457f586b5571a16 Mon Sep 17 00:00:00 2001 From: trivernis Date: Sun, 31 Oct 2021 10:32:34 +0100 Subject: [PATCH] Fix typo and add tracing Signed-off-by: trivernis --- src/ipc/context.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ipc/context.rs b/src/ipc/context.rs index 34894ce4..f8f7c30b 100644 --- a/src/ipc/context.rs +++ b/src/ipc/context.rs @@ -122,7 +122,7 @@ where T: Clone, { fn drop(&mut self) { - self.count.fetch_sub(1, Ordering::Relaxed); + self.release(); } } @@ -139,12 +139,19 @@ where /// Acquires the context by adding 1 to the count and /// returning the cloned variant - pub(crate) fn aqcuire(&self) -> Self { + #[tracing::instrument(level = "trace", skip_all)] + pub(crate) fn acquire(&self) -> Self { self.count.fetch_add(1, Ordering::Relaxed); self.clone() } + /// Releases the connection by subtracting from the stored count + #[tracing::instrument(level = "trace", skip_all)] + pub(crate) fn release(&self) { + self.count.fetch_sub(1, Ordering::Relaxed); + } + pub(crate) fn count(&self) -> usize { self.count.load(Ordering::Relaxed) } @@ -166,6 +173,6 @@ impl PooledContext { .iter() .min_by_key(|c| c.count()) .unwrap() - .aqcuire() + .acquire() } }