execq icon indicating copy to clipboard operation
execq copied to clipboard

Fix race condition when notifying workers of new tasks

Open jorgenpt opened this issue 2 weeks ago • 0 comments

Fix a race condition when we notify workers of new tasks, where m_checkNextTask would be cleared before we took a task item, which would cause a subsequent notifyWorker call on the same worker to return true while the worker was currently processing a task, causing notifyOneWorker to attempt to "wake up" a worker that was already processing a task, rather than notify another worker that was sitting idle.

In addition:

  • Simplify the logic by using the mutex and regular booleans instead of relying on atomics
  • Release the locks before signaling the condition variables, to reduce lock contention from the woken-up thread

jorgenpt avatar Jan 08 '26 20:01 jorgenpt