Bug 1161405. Part 1 - improve parallelism of nsThreadPool by taking the number of pending events into account when spawning a new thread. r=nfroyd.

This commit is contained in:
JW Wang
2015-05-09 07:32:30 +08:00
parent d76434982a
commit 8e689713fa
3 changed files with 42 additions and 1 deletions

View File

@@ -82,7 +82,10 @@ nsThreadPool::PutEvent(nsIRunnable* aEvent)
MOZ_ASSERT(mIdleCount <= (uint32_t)mThreads.Count(), "oops");
// Make sure we have a thread to service this event.
if (mIdleCount == 0 && mThreads.Count() < (int32_t)mThreadLimit) {
if (mThreads.Count() < (int32_t)mThreadLimit &&
// Spawn a new thread if we don't have enough idle threads to serve
// pending events immediately.
mEvents.Count() >= mIdleCount) {
spawnThread = true;
}