Skip to content

Commit

Permalink
Check active even if Condvar times out in PeriodicWorker (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
SpriteOvO authored Feb 11, 2024
1 parent 47739b1 commit 40e5c18
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions spdlog/src/periodic_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ impl PeriodicWorker {
Self {
active: active.clone(),
thread: Some(thread::spawn(move || loop {
let guard = active.0.lock_expect();
let (_, res) = active
let flag = active.0.lock_expect();
let (flag, res) = active
.1
.wait_timeout_while(guard, interval, |active| *active)
.wait_timeout_while(flag, interval, |flag| *flag)
.unwrap();

if !res.timed_out() || !callback() {
if !res.timed_out() || !*flag || !callback() {
return;
}
})),
Expand Down

0 comments on commit 40e5c18

Please sign in to comment.