This patch should fix an nondeterministic error in TestStackCoreScriptedProcess.
In order to test both the multithreading capability and shared library
loading in Scripted Processes, the test would create multiple threads
that would take the same variable as a reference.
The first thread would alter the value and the second thread would
monitor the value until it gets altered. This assumed a certain ordering
regarding the std::thread spawning, however the ordering was not
always guaranteed at runtime.
To fix that, the test now makes use of a std::condition_variable
shared between the each thread. On the former, it will notify the other
thread when the variable gets initialized or updated and on the latter,
it will wait until the variable it receives a new notification.
This should fix the data racing issue while preserving the testing
coverage.
rdar://98678134
Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
Unless I misunderstand the code, I don't think you need this while loop anymore. baz should block until the condition variable is changed.