Skip to content

Conversation

@jorgenpt
Copy link

@jorgenpt jorgenpt commented Jan 8, 2026

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

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant