From a866a6dfb4f1b727ca506b6f94687eb73e444b7d Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Mon, 1 Aug 2016 09:45:31 -0700 Subject: [PATCH] Bug 1290317 - Switch the SharedImmutableStringsCache jsapi-test over to js::Thread instead of PRThread; r=terrence --- .../testSharedImmutableStringsCache.cpp | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/js/src/jsapi-tests/testSharedImmutableStringsCache.cpp b/js/src/jsapi-tests/testSharedImmutableStringsCache.cpp index dc3eb589798b..920618928e08 100644 --- a/js/src/jsapi-tests/testSharedImmutableStringsCache.cpp +++ b/js/src/jsapi-tests/testSharedImmutableStringsCache.cpp @@ -8,7 +8,7 @@ #include "js/Vector.h" #include "jsapi-tests/tests.h" - +#include "threading/Thread.h" #include "vm/SharedImmutableStringsCache.h" const int NUM_THREADS = 256; @@ -34,10 +34,8 @@ struct CacheAndIndex }; static void -getString(void* data) +getString(CacheAndIndex* cacheAndIndex) { - auto cacheAndIndex = reinterpret_cast(data); - for (int i = 0; i < NUM_ITERATIONS; i++) { auto str = STRINGS[cacheAndIndex->index % NUM_STRINGS]; @@ -64,25 +62,17 @@ BEGIN_TEST(testSharedImmutableStringsCache) CHECK(maybeCache.isSome()); auto& cache = *maybeCache; - js::Vector threads(cx); + js::Vector threads(cx); CHECK(threads.reserve(NUM_THREADS)); for (auto i : mozilla::MakeRange(NUM_THREADS)) { auto cacheAndIndex = js_new(&cache, i); CHECK(cacheAndIndex); - auto thread = PR_CreateThread(PR_USER_THREAD, - getString, - (void *) cacheAndIndex, - PR_PRIORITY_NORMAL, - PR_LOCAL_THREAD, - PR_JOINABLE_THREAD, - 0); - CHECK(thread); - threads.infallibleAppend(thread); + threads.infallibleEmplaceBack(getString, cacheAndIndex); } - for (auto thread : threads) - CHECK(PR_JoinThread(thread) == PR_SUCCESS); + for (auto& thread : threads) + thread.join(); return true; }