Bug 875125 - Construct worker thread's PerThreadData before spawning actual thread on a CLOSED TREE

This commit is contained in:
Brian Hackett 2013-07-19 12:57:12 -06:00
parent 06b9c176de
commit f7d352eb76

View File

@ -311,6 +311,8 @@ WorkerThreadState::init(JSRuntime *rt)
for (size_t i = 0; i < numThreads; i++) {
WorkerThread &helper = threads[i];
helper.runtime = rt;
helper.threadData.construct(rt);
helper.threadData.ref().addToThreadList();
helper.thread = PR_CreateThread(PR_USER_THREAD,
WorkerThread::ThreadMain, &helper,
PR_PRIORITY_NORMAL, PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);
@ -322,8 +324,6 @@ WorkerThreadState::init(JSRuntime *rt)
numThreads = 0;
return false;
}
helper.threadData.construct(rt);
helper.threadData.ref().addToThreadList();
}
resetAsmJSFailureState();
@ -439,9 +439,7 @@ WorkerThread::destroy()
{
WorkerThreadState &state = *runtime->workerThreadState;
if (!thread)
return;
if (thread) {
{
AutoLockWorkerThreadState lock(runtime);
terminate = true;
@ -451,6 +449,9 @@ WorkerThread::destroy()
}
PR_JoinThread(thread);
}
if (!threadData.empty())
threadData.ref().removeFromThreadList();
}