Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Unified Diff: base/task_scheduler/scheduler_worker_pool_impl.cc

Issue 2412983003: TaskScheduler: Put an ALIVE SchedulerWorker on top of the idle stack. (Closed)
Patch Set: CR robliao #3 Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/task_scheduler/scheduler_worker_pool_impl.cc
diff --git a/base/task_scheduler/scheduler_worker_pool_impl.cc b/base/task_scheduler/scheduler_worker_pool_impl.cc
index dc040301ca31af4868522b3983b112f293e0d28e..e804bbd779ab06f3dd5070d2fcfa9d2fb3103fc0 100644
--- a/base/task_scheduler/scheduler_worker_pool_impl.cc
+++ b/base/task_scheduler/scheduler_worker_pool_impl.cc
@@ -698,12 +698,15 @@ bool SchedulerWorkerPoolImpl::Initialize(
DCHECK(workers_.empty());
for (size_t i = 0; i < max_threads; ++i) {
+ // The last SchedulerWorker added to the idle stack should be ALIVE.
+ const SchedulerWorker::InitialState initial_state =
+ (i == max_threads - 1) ? SchedulerWorker::InitialState::ALIVE
+ : SchedulerWorker::InitialState::DETACHED;
std::unique_ptr<SchedulerWorker> worker = SchedulerWorker::Create(
priority_hint, MakeUnique<SchedulerWorkerDelegateImpl>(
this, re_enqueue_sequence_callback,
&shared_priority_queue_, static_cast<int>(i)),
- task_tracker_, i == 0 ? SchedulerWorker::InitialState::ALIVE
- : SchedulerWorker::InitialState::DETACHED);
+ task_tracker_, initial_state);
if (!worker)
break;
idle_workers_stack_.Push(worker.get());
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698