Bug 1202667 - make TaskQueue dispatching slightly more efficient; r=mccr8
authorNathan Froyd <froydnj@mozilla.com>
Mon, 07 Sep 2015 19:51:54 -0400
changeset 294036 348b09b8d6439b13be42b0dabf3afa60866bcf7b
parent 294035 f136c4f7e6fea9b3bca187bf1952a5e59f8544fd
child 294037 fe19d71aae51324e6babf07ad9eac0bea843c2f6
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1202667
milestone43.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 1202667 - make TaskQueue dispatching slightly more efficient; r=mccr8 We're already holding a reference to the Runner prior to dispatching it to the thread pool; we can pass that reference in rather than requiring the thread pool to take a new reference to it.
xpcom/threads/TaskQueue.cpp
--- a/xpcom/threads/TaskQueue.cpp
+++ b/xpcom/threads/TaskQueue.cpp
@@ -58,17 +58,17 @@ TaskQueue::DispatchLocked(already_AddRef
   if (mIsShutdown) {
     return NS_ERROR_FAILURE;
   }
   mTasks.push(r.forget());
   if (mIsRunning) {
     return NS_OK;
   }
   nsRefPtr<nsIRunnable> runner(new Runner(this));
-  nsresult rv = mPool->Dispatch(runner, NS_DISPATCH_NORMAL);
+  nsresult rv = mPool->Dispatch(runner.forget(), NS_DISPATCH_NORMAL);
   if (NS_FAILED(rv)) {
     NS_WARNING("Failed to dispatch runnable to run TaskQueue");
     return rv;
   }
   mIsRunning = true;
 
   return NS_OK;
 }