diff --git a/js/src/jsapi-tests/testThreadingExclusiveData.cpp b/js/src/jsapi-tests/testThreadingExclusiveData.cpp index 1e8ec68ad9ce..04b16031b5c7 100644 --- a/js/src/jsapi-tests/testThreadingExclusiveData.cpp +++ b/js/src/jsapi-tests/testThreadingExclusiveData.cpp @@ -8,6 +8,7 @@ #include "js/Vector.h" #include "jsapi-tests/tests.h" #include "threading/ExclusiveData.h" +#include "threading/Thread.h" // One thread for each bit in our counter. const static uint8_t NumThreads = 64; @@ -43,10 +44,8 @@ printDiagnosticMessage(uint64_t seen) } void -setBitAndCheck(void* arg) +setBitAndCheck(CounterAndBit& counterAndBit) { - auto& counterAndBit = *static_cast(arg); - while (true) { { // Set our bit. Repeatedly setting it is idempotent. @@ -72,26 +71,17 @@ BEGIN_TEST(testExclusiveData) { js::ExclusiveData counter(0); - js::Vector threads(cx); + js::Vector threads(cx); CHECK(threads.reserve(NumThreads)); for (auto i : mozilla::MakeRange(NumThreads)) { auto counterAndBit = js_new(i, counter); CHECK(counterAndBit); - auto thread = PR_CreateThread(PR_USER_THREAD, - setBitAndCheck, - (void *) counterAndBit, - PR_PRIORITY_NORMAL, - PR_LOCAL_THREAD, - PR_JOINABLE_THREAD, - 0); - CHECK(thread); - threads.infallibleAppend(thread); + CHECK(threads.emplaceBack(setBitAndCheck, *counterAndBit)); } - for (auto thread : threads) { - CHECK(PR_JoinThread(thread) == PR_SUCCESS); - } + for (auto& thread : threads) + thread.join(); return true; }