Commit edc4f91e authored by Etienne Pierre-Doray's avatar Etienne Pierre-Doray Committed by Commit Bot

[TaskScheduler]: Spawn workers from GetWork().

In an effort to avoid creating threads from the main thread,
this CL avoids the creation of a new idle thread after waking up
the current idle thread from the main thread.
This is done by moving a call to MaintainAtLeastOneIdleWorkerLockRequired()
from WakeUpOneWorkerLockRequired() to GetWork().
Note that a call to MaintainAtLeastOneIdleWorkerLockRequired() is still
done before waking up a worker in WakeUpOneWorkerLockRequired(), in case no
idle thread was created yet.

Bug: 847501
Change-Id: Ib3903c117a781a72f9d6a6aaeceee6554e5b9803
Reviewed-on: https://chromium-review.googlesource.com/c/1338382
Commit-Queue: Etienne Pierre-Doray <etiennep@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609848}
parent 396a0004
......@@ -482,6 +482,9 @@ SchedulerWorkerPoolImpl::SchedulerWorkerDelegateImpl::GetWork(
return nullptr;
}
// Replace this worker if it was the last one, capacity permitting.
outer_->MaintainAtLeastOneIdleWorkerLockRequired();
// Excess workers should not get work, until they are no longer excess (i.e.
// max tasks increases or another worker cleans up). This ensures that if we
// have excess workers in the pool, they get a chance to no longer be excess
......@@ -844,10 +847,6 @@ bool SchedulerWorkerPoolImpl::WakeUpOneWorkerLockRequired() {
}
}
// Ensure that there is one worker that can run tasks on top of the idle
// stack, capacity permitting.
MaintainAtLeastOneIdleWorkerLockRequired();
return true;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment