From d8abc58590eb3f0e61fb3b9eb1d79597ca8a45ca Mon Sep 17 00:00:00 2001 From: romir kulshrestha Date: Wed, 4 Mar 2026 22:52:10 +0100 Subject: maybe race condition fix? --- .gitignore | 1 + oryxc/src/compiler.rs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index 14e38dd..72e2ff5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ target/ unigen/data/ +.idea/ diff --git a/oryxc/src/compiler.rs b/oryxc/src/compiler.rs index 4ae8577..f630166 100644 --- a/oryxc/src/compiler.rs +++ b/oryxc/src/compiler.rs @@ -195,6 +195,10 @@ fn worker_loop( } let Some(job) = find_task(&queue, &state.globalq, &stealers) else { + // no work available; check termination condition before parking to avoid missed wakeups + if state.njobs.load(Ordering::Acquire) == 0 { + break; + } thread::park(); continue; }; @@ -258,6 +262,9 @@ fn worker_loop( // njobs is 0; wake all threads so they can observe the termination // condition and exit. state.wake_all(); + + // break here to avoid unnecessary steal attempts after work is done. + break; } } } -- cgit v1.2.3