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()); |