From 2e1ec8d9ddec8f42ebabd3099836d743e448f142 Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Tue, 20 Dec 2016 14:20:48 +0100 Subject: [PATCH] Bug 1323100 - Use nsThreadPoolNaming::GetNextThreadName and NS_NewNamedThread in the DecodePool. r=froydnj MozReview-Commit-ID: CAbaAe0bKe8 --HG-- extra : rebase_source : c0329013903fa27812291ad0801c032a86740ee9 --- image/DecodePool.cpp | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/image/DecodePool.cpp b/image/DecodePool.cpp index 9aa3d58229f4..8053b2f9d19d 100644 --- a/image/DecodePool.cpp +++ b/image/DecodePool.cpp @@ -60,14 +60,6 @@ public: , mShuttingDown(false) { } - /// Initialize the current thread for use by the decode pool. - void InitCurrentThread() - { - MOZ_ASSERT(!NS_IsMainThread()); - - mThreadNaming.SetThreadPoolName(NS_LITERAL_CSTRING("ImgDecoder")); - } - /// Shut down the provided decode pool thread. static void ShutdownThread(nsIThread* aThisThread) { @@ -135,6 +127,12 @@ public: } while (true); } + nsresult CreateThread(nsIThread** aThread, nsIRunnable* aInitialEvent) + { + return NS_NewNamedThread(mThreadNaming.GetNextThreadName("ImgDecoder"), + aThread, aInitialEvent); + } + private: ~DecodePoolImpl() { } @@ -166,22 +164,11 @@ public: NS_IMETHOD Run() override { -#ifdef MOZ_ENABLE_PROFILER_SPS - char stackBaseGuess; // Need to be the first variable of main loop function. -#endif // MOZ_ENABLE_PROFILER_SPS - MOZ_ASSERT(!NS_IsMainThread()); - mImpl->InitCurrentThread(); - nsCOMPtr thisThread; nsThreadManager::get().GetCurrentThread(getter_AddRefs(thisThread)); -#ifdef MOZ_ENABLE_PROFILER_SPS - // InitCurrentThread() has assigned the thread name. - profiler_register_thread(PR_GetThreadName(PR_GetCurrentThread()), &stackBaseGuess); -#endif // MOZ_ENABLE_PROFILER_SPS - do { Work work = mImpl->PopWork(); switch (work.mType) { @@ -272,7 +259,7 @@ DecodePool::DecodePool() for (uint32_t i = 0 ; i < limit ; ++i) { nsCOMPtr worker = new DecodePoolWorker(mImpl); nsCOMPtr thread; - nsresult rv = NS_NewThread(getter_AddRefs(thread), worker); + nsresult rv = mImpl->CreateThread(getter_AddRefs(thread), worker); MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv) && thread, "Should successfully create image decoding threads"); mThreads.AppendElement(Move(thread));