From d26447e811bf30bfbb7c7b92b0bbdd9188547095 Mon Sep 17 00:00:00 2001 From: null8626 Date: Wed, 3 Jan 2024 22:37:50 +0700 Subject: [PATCH] refactor: reorder stuff --- src/autoposter.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/autoposter.rs b/src/autoposter.rs index 759656f..21b1f11 100644 --- a/src/autoposter.rs +++ b/src/autoposter.rs @@ -72,13 +72,12 @@ impl AutoposterHandle { /// .await; /// ``` pub async fn feed(&self, new_stats: Stats) { - { + if self.data.sem.available_permits() < 1 { let mut lock = self.data.stats.lock().await; - *lock = new_stats; - }; - if self.data.sem.available_permits() == 0 { self.data.sem.add_permits(1); + + *lock = new_stats; } } }