Skip to content

Commit

Permalink
Fix multiple passes
Browse files Browse the repository at this point in the history
  • Loading branch information
langston-barrett committed Dec 23, 2024
1 parent 822bbd2 commit f5f1ad5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/treereduce/src/reduce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,12 @@ fn dispatch<T: Check + Send + Sync>(
/// Main function for each thread
fn work<T: Check + Send + Sync>(ctx: &Ctx<T>, num_threads: usize) -> Result<(), ReductionError> {
static IDLE_THREADS: AtomicUsize = AtomicUsize::new(0);
// Since IDLE_THREADS is static, decrement for second and later passes
let idle = IDLE_THREADS.load(atomic::Ordering::Acquire);
if idle > 0 {
IDLE_THREADS.store(idle - 1, atomic::Ordering::Release)
}

let tctx = ThreadCtx::new(ctx);
let mut idle = false;
// Quit if all threads are idle and there are no remaining tasks
Expand Down

0 comments on commit f5f1ad5

Please sign in to comment.