From 8271d832b5c1ec4c5a6cf05d0301949cbe1fee0e Mon Sep 17 00:00:00 2001 From: Asuna Date: Mon, 5 Feb 2024 14:16:51 +0800 Subject: [PATCH] Check `active` even if `Condvar` is timed out in `PeriodicWorker` --- spdlog/src/periodic_worker.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spdlog/src/periodic_worker.rs b/spdlog/src/periodic_worker.rs index 032bfa85..d3cdedf4 100644 --- a/spdlog/src/periodic_worker.rs +++ b/spdlog/src/periodic_worker.rs @@ -22,12 +22,12 @@ impl PeriodicWorker { active: active.clone(), thread: Some(thread::spawn(move || loop { let guard = active.0.lock_expect(); - let (_, res) = active + let (guard, res) = active .1 .wait_timeout_while(guard, interval, |active| *active) .unwrap(); - if !res.timed_out() || !callback() { + if !res.timed_out() || !*guard || !callback() { return; } })),