Bug 1323100 - Use nsThreadPoolNaming::GetNextThreadName and NS_NewNamedThread in nsThreadPool. r?froydnj
MozReview-Commit-ID: 6IB5yvJtAQm
--- a/xpcom/threads/nsThreadPool.cpp
+++ b/xpcom/threads/nsThreadPool.cpp
@@ -99,18 +99,19 @@ nsThreadPool::PutEvent(already_AddRefed<
}
LOG(("THRD-P(%p) put [spawn=%d]\n", this, spawnThread));
if (!spawnThread) {
return NS_OK;
}
nsCOMPtr<nsIThread> thread;
- nsThreadManager::get().NewThread(0, stackSize, getter_AddRefs(thread));
- if (NS_WARN_IF(!thread)) {
+ nsresult rv = NS_NewNamedThread(mThreadNaming.GetNextThreadName(mName),
+ getter_AddRefs(thread), nullptr, stackSize);
+ if (NS_WARN_IF(NS_FAILED(rv))) {
return NS_ERROR_UNEXPECTED;
}
bool killThread = false;
{
MutexAutoLock lock(mMutex);
if (mThreads.Count() < (int32_t)mThreadLimit) {
mThreads.AppendObject(thread);
@@ -147,18 +148,16 @@ nsThreadPool::ShutdownThread(nsIThread*
// shutdown aThread from the main thread.
NS_DispatchToMainThread(NewRunnableMethod(aThread,
&nsIThread::AsyncShutdown));
}
NS_IMETHODIMP
nsThreadPool::Run()
{
- mThreadNaming.SetThreadPoolName(mName);
-
LOG(("THRD-P(%p) enter %s\n", this, mName.BeginReading()));
nsCOMPtr<nsIThread> current;
nsThreadManager::get().GetCurrentThread(getter_AddRefs(current));
bool shutdownThreadOnExit = false;
bool exitThread = false;
bool wasIdle = false;