Skip to content

Commit f5f1ad5

Browse files
Fix multiple passes
1 parent 822bbd2 commit f5f1ad5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

crates/treereduce/src/reduce.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,12 @@ fn dispatch<T: Check + Send + Sync>(
504504
/// Main function for each thread
505505
fn work<T: Check + Send + Sync>(ctx: &Ctx<T>, num_threads: usize) -> Result<(), ReductionError> {
506506
static IDLE_THREADS: AtomicUsize = AtomicUsize::new(0);
507+
// Since IDLE_THREADS is static, decrement for second and later passes
508+
let idle = IDLE_THREADS.load(atomic::Ordering::Acquire);
509+
if idle > 0 {
510+
IDLE_THREADS.store(idle - 1, atomic::Ordering::Release)
511+
}
512+
507513
let tctx = ThreadCtx::new(ctx);
508514
let mut idle = false;
509515
// Quit if all threads are idle and there are no remaining tasks

0 commit comments

Comments
 (0)