Bug 1315187 - Assert that thread calling IdleDispatch is the thread that will run it. r=smaug
authorAndreas Farre <farre@mozilla.com>
Fri, 04 Nov 2016 09:08:31 +0100
changeset 347770 579eddccb01aafc9ece22a1b69530a03c8c2a79d
parent 347769 720fa40353a7e2c671c0fae81865b4deb573f64a
child 347771 e38f9ff87d2ea70082a30d9c41a226753165226f
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1315187
milestone52.0a1
Bug 1315187 - Assert that thread calling IdleDispatch is the thread that will run it. r=smaug MozReview-Commit-ID: LGrKeIUaGCD
xpcom/threads/nsThread.cpp
--- a/xpcom/threads/nsThread.cpp
+++ b/xpcom/threads/nsThread.cpp
@@ -977,16 +977,22 @@ nsThread::RegisterIdlePeriod(already_Add
   MutexAutoLock lock(mLock);
   mIdlePeriod = aIdlePeriod;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsThread::IdleDispatch(already_AddRefed<nsIRunnable> aEvent)
 {
+  // Currently the only supported idle dispatch is from the same
+  // thread. To support idle dispatch from another thread we need to
+  // support waking threads that are waiting for an event queue that
+  // isn't mIdleEvents.
+  MOZ_ASSERT(PR_GetCurrentThread() == mThread);
+
   MutexAutoLock lock(mLock);
   LeakRefPtr<nsIRunnable> event(Move(aEvent));
 
   if (NS_WARN_IF(!event)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   if (mEventsAreDoomed) {