mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-27 04:38:02 +00:00
Bug 1323100 - Use nsThreadPoolNaming::GetNextThreadName and NS_NewNamedThread in the DecodePool. r=froydnj
MozReview-Commit-ID: CAbaAe0bKe8 --HG-- extra : rebase_source : c0329013903fa27812291ad0801c032a86740ee9
This commit is contained in:
parent
9c6944dca7
commit
2e1ec8d9dd
@ -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<nsIThread> 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<nsIRunnable> worker = new DecodePoolWorker(mImpl);
|
||||
nsCOMPtr<nsIThread> 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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user