Improve parallelism of nsThreadPool

By taking the number of pending events into account when spawning a new thread
This commit is contained in:
trav90
2017-06-05 20:52:24 -05:00
committed by Roy Tam
parent eba13a9563
commit b30a15c415
3 changed files with 42 additions and 1 deletions
+4 -1
View File
@@ -84,7 +84,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;
}