Bug 857367 - Remove DecodePool::mShuttingDown, which is unnecessary. r=seth
authorJoe Drew <joe@drew.ca>
Wed, 17 Apr 2013 20:05:19 -0400
changeset 129206 b687a2bd8efa3aebe8c1f03b596c84f675cedaef
parent 129205 cffcceab1b0d4d870e7a72576d1df8230b388626
child 129207 1d31d983075a85f966d09130c3a608da197eb039
push id24562
push userryanvm@gmail.com
push dateFri, 19 Apr 2013 01:24:04 +0000
treeherdermozilla-central@f8d27fe5d7c0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersseth
bugs857367
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 857367 - Remove DecodePool::mShuttingDown, which is unnecessary. r=seth
image/src/RasterImage.cpp
image/src/RasterImage.h
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -3509,18 +3509,17 @@ RasterImage::DecodePool::Singleton()
     sSingleton = new DecodePool();
     ClearOnShutdown(&sSingleton);
   }
 
   return sSingleton;
 }
 
 RasterImage::DecodePool::DecodePool()
-  : mThreadPoolMutex("Thread Pool")
-  , mShuttingDown(false)
+ : mThreadPoolMutex("Thread Pool")
 {
   if (gMultithreadedDecoding) {
     mThreadPool = do_CreateInstance(NS_THREADPOOL_CONTRACTID);
     if (mThreadPool) {
       mThreadPool->SetName(NS_LITERAL_CSTRING("ImageDecoder"));
       if (gDecodingThreadLimit <= 0) {
         mThreadPool->SetThreadLimit(std::max(PR_GetNumberOfProcessors() - 1, 1));
       } else {
@@ -3547,17 +3546,16 @@ RasterImage::DecodePool::Observe(nsISupp
   NS_ASSERTION(strcmp(topic, "xpcom-shutdown-threads") == 0, "oops");
 
   nsCOMPtr<nsIThreadPool> threadPool;
 
   {
     MutexAutoLock threadPoolLock(mThreadPoolMutex);
     threadPool = mThreadPool;
     mThreadPool = nullptr;
-    mShuttingDown = true;
   }
 
   if (threadPool) {
     threadPool->Shutdown();
   }
 
   return NS_OK;
 }
@@ -3579,20 +3577,19 @@ RasterImage::DecodePool::RequestDecode(R
         aImg->mDecodeRequest->mRequestStatus == DecodeRequest::REQUEST_ACTIVE) {
       // The image is already in our list of images to decode, or currently being
       // decoded, so we don't have to do anything else.
       return;
     }
 
     aImg->mDecodeRequest->mRequestStatus = DecodeRequest::REQUEST_PENDING;
     nsRefPtr<DecodeJob> job = new DecodeJob(aImg->mDecodeRequest, aImg);
+
     MutexAutoLock threadPoolLock(mThreadPoolMutex);
-    if (mShuttingDown) {
-      // Just drop the job on the floor; we won't need it.
-    } else if (!gMultithreadedDecoding || !mThreadPool) {
+    if (!gMultithreadedDecoding || !mThreadPool) {
       NS_DispatchToMainThread(job);
     } else {
       mThreadPool->Dispatch(job, nsIEventTarget::DISPATCH_NORMAL);
     }
   }
 }
 
 void
--- a/image/src/RasterImage.h
+++ b/image/src/RasterImage.h
@@ -520,22 +520,21 @@ private:
 
     private:
       nsRefPtr<DecodeRequest> mRequest;
       nsRefPtr<RasterImage> mImage;
     };
 
   private: /* members */
 
-    // mThreadPoolMutex protects both mThreadPool and mShuttingDown. For all
-    // RasterImages R, R::mDecodingMutex must be acquired before
-    // mThreadPoolMutex if both are acquired; the other order may cause deadlock.
+    // mThreadPoolMutex protects mThreadPool. For all RasterImages R,
+    // R::mDecodingMutex must be acquired before mThreadPoolMutex if both are
+    // acquired; the other order may cause deadlock.
     mozilla::Mutex          mThreadPoolMutex;
     nsCOMPtr<nsIThreadPool> mThreadPool;
-    bool                    mShuttingDown;
   };
 
   class DecodeDoneWorker : public nsRunnable
   {
   public:
     /**
      * Called by the DecodePool with an image when it's done some significant
      * portion of decoding that needs to be notified about.