Add optional testing hook for blocking_concurrent_queue#59
Merged
bghgary merged 3 commits intomicrosoft:masterfrom Apr 2, 2026
Merged
Add optional testing hook for blocking_concurrent_queue#59bghgary merged 3 commits intomicrosoft:masterfrom
bghgary merged 3 commits intomicrosoft:masterfrom
Conversation
63bc00d to
d5804f8
Compare
This was referenced Apr 2, 2026
0afc70e to
fa054fd
Compare
fa054fd to
8328898
Compare
There was a problem hiding this comment.
Pull request overview
Adds a test-only hook to arcana::blocking_concurrent_queue to allow deterministic reproduction of lost-wakeup races by running a callback immediately before condition_variable::wait() while the queue mutex is held.
Changes:
- Introduces a global (test-only)
beforeWaitCallbackandset_before_wait_callback()setter behindARCANA_TESTING_HOOKS. - Invokes the callback right before
m_dataReady.wait(lock)in bothinternal_pop()andinternal_drain().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ryantrem
approved these changes
Apr 2, 2026
Add a global before-wait callback invoked while holding the queue mutex, right before condition_variable::wait(). This enables deterministic testing of lost-wakeup race conditions in code that uses the queue. Behind #ifdef ARCANA_TESTING_HOOKS -- zero cost when not enabled. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
8328898 to
cf25e34
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bghgary
added a commit
to bghgary/JsRuntimeHost
that referenced
this pull request
Apr 2, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
bghgary
added a commit
to bghgary/JsRuntimeHost
that referenced
this pull request
Apr 3, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a global before-wait callback to blocking_concurrent_queue, invoked while holding the queue mutex right before condition_variable::wait().
Motivation
This enables deterministic testing of lost-wakeup race conditions. By sleeping in the callback (while holding the mutex), a test can guarantee a worker thread is between the condition check and wait(). Code that coordinates through push() (which acquires the mutex) will block until the worker enters wait() and deliver the notification correctly. Code that uses bare notify_all() (without the mutex) will lose the signal.
Changes
All behind ARCANA_TESTING_HOOKS -- zero cost when not enabled. No other files changed.
Usage
Used by BabylonJS/JsRuntimeHost#146 to deterministically reproduce a deadlock in AppRuntime shutdown.