Bug 1315187 - Assert that thread calling IdleDispatch is the thread that will run it. r?smaug
MozReview-Commit-ID: LGrKeIUaGCD
--- 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) {