Back out changeset b5ec7338bddf (bug 1236789) on a CLOSED TREE for causing assertions on most (but not all) debug test runs.

This commit is contained in:
L. David Baron 2016-02-24 15:45:40 -08:00
parent 05ebec7baa
commit d5e0278a54
5 changed files with 5 additions and 24 deletions

View File

@ -55,11 +55,6 @@ public:
// Forward behaviour to wrapped thread pool implementation.
NS_FORWARD_SAFE_NSITHREADPOOL(mPool);
// Call this when dispatching from an event on the same
// threadpool that is about to complete. We should not create a new thread
// in that case since a thread is about to become idle.
nsresult TailDispatch(nsIRunnable *event) { return Dispatch(event, NS_DISPATCH_TAIL); }
NS_IMETHOD DispatchFromScript(nsIRunnable *event, uint32_t flags) override {
return Dispatch(event, flags);
}

View File

@ -193,7 +193,7 @@ TaskQueue::Runner::Run()
// run in a loop here so that we don't hog the thread pool. This means we may
// run on another thread next time, but we rely on the memory fences from
// mQueueMonitor for thread safety of non-threadsafe tasks.
nsresult rv = mQueue->mPool->TailDispatch(this);
nsresult rv = mQueue->mPool->Dispatch(this, NS_DISPATCH_NORMAL);
if (NS_FAILED(rv)) {
// Failed to dispatch, shutdown!
MonitorAutoLock mon(mQueue->mQueueMonitor);

View File

@ -40,18 +40,6 @@ interface nsIEventTarget : nsISupports
*/
const unsigned long DISPATCH_SYNC = 1;
/**
* This flag specifies that the dispatch is occurring from a running event
* that was dispatched to the same event target, and that event is about to
* finish.
*
* A thread pool can use this as an optimization hint to not spin up
* another thread, since the current thread is about to become idle.
*
* These events are always async.
*/
const unsigned long DISPATCH_TAIL = 2;
/**
* Check to see if this event target is associated with the current thread.
*
@ -103,5 +91,4 @@ interface nsIEventTarget : nsISupports
// convenient aliases:
#define NS_DISPATCH_NORMAL nsIEventTarget::DISPATCH_NORMAL
#define NS_DISPATCH_SYNC nsIEventTarget::DISPATCH_SYNC
#define NS_DISPATCH_TAIL nsIEventTarget::DISPATCH_TAIL
%}

View File

@ -64,11 +64,11 @@ nsresult
nsThreadPool::PutEvent(nsIRunnable* aEvent)
{
nsCOMPtr<nsIRunnable> event(aEvent);
return PutEvent(event.forget(), 0);
return PutEvent(event.forget());
}
nsresult
nsThreadPool::PutEvent(already_AddRefed<nsIRunnable>&& aEvent, uint32_t aFlags)
nsThreadPool::PutEvent(already_AddRefed<nsIRunnable>&& aEvent)
{
// Avoid spawning a new thread while holding the event queue lock...
@ -86,7 +86,6 @@ nsThreadPool::PutEvent(already_AddRefed<nsIRunnable>&& aEvent, uint32_t aFlags)
// Make sure we have a thread to service this event.
if (mThreads.Count() < (int32_t)mThreadLimit &&
!(aFlags & NS_DISPATCH_TAIL) &&
// Spawn a new thread if we don't have enough idle threads to serve
// pending events immediately.
mEvents.Count(lock) >= mIdleCount) {
@ -273,7 +272,7 @@ nsThreadPool::Dispatch(already_AddRefed<nsIRunnable>&& aEvent, uint32_t aFlags)
}
} else {
NS_ASSERTION(aFlags == NS_DISPATCH_NORMAL, "unexpected dispatch flags");
PutEvent(Move(aEvent), aFlags);
PutEvent(Move(aEvent));
}
return NS_OK;
}

View File

@ -37,7 +37,7 @@ private:
void ShutdownThread(nsIThread* aThread);
nsresult PutEvent(nsIRunnable* aEvent);
nsresult PutEvent(already_AddRefed<nsIRunnable>&& aEvent, uint32_t aFlags);
nsresult PutEvent(already_AddRefed<nsIRunnable>&& aEvent);
nsCOMArray<nsIThread> mThreads;
mozilla::Mutex mMutex;