| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/task_scheduler/scheduler_worker_pool_impl.h" | 5 #include "base/task_scheduler/scheduler_worker_pool_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 num_wake_ups_before_start_ + | 258 num_wake_ups_before_start_ + |
| 259 (params.standby_thread_policy() == | 259 (params.standby_thread_policy() == |
| 260 SchedulerWorkerPoolParams::StandbyThreadPolicy::ONE | 260 SchedulerWorkerPoolParams::StandbyThreadPolicy::ONE |
| 261 ? 1 | 261 ? 1 |
| 262 : 0); | 262 : 0); |
| 263 | 263 |
| 264 // Create workers in reverse order of index so that the worker with the | 264 // Create workers in reverse order of index so that the worker with the |
| 265 // highest index is at the bottom of the idle stack. | 265 // highest index is at the bottom of the idle stack. |
| 266 for (int index = params.max_threads() - 1; index >= 0; --index) { | 266 for (int index = params.max_threads() - 1; index >= 0; --index) { |
| 267 workers_[index] = make_scoped_refptr(new SchedulerWorker( | 267 workers_[index] = make_scoped_refptr(new SchedulerWorker( |
| 268 params.priority_hint(), | 268 priority_hint_, |
| 269 MakeUnique<SchedulerWorkerDelegateImpl>( | 269 MakeUnique<SchedulerWorkerDelegateImpl>( |
| 270 this, re_enqueue_sequence_callback_, index), | 270 this, re_enqueue_sequence_callback_, index), |
| 271 task_tracker_, params.backward_compatibility(), | 271 task_tracker_, params.backward_compatibility(), |
| 272 index < num_alive_workers ? SchedulerWorker::InitialState::ALIVE | 272 index < num_alive_workers ? SchedulerWorker::InitialState::ALIVE |
| 273 : SchedulerWorker::InitialState::DETACHED)); | 273 : SchedulerWorker::InitialState::DETACHED)); |
| 274 | 274 |
| 275 // Put workers that won't be woken up at the end of this method on the | 275 // Put workers that won't be woken up at the end of this method on the |
| 276 // idle stack. | 276 // idle stack. |
| 277 if (index >= num_wake_ups_before_start_) | 277 if (index >= num_wake_ups_before_start_) |
| 278 idle_workers_stack_.Push(workers_[index].get()); | 278 idle_workers_stack_.Push(workers_[index].get()); |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 AutoSchedulerLock auto_lock(idle_workers_stack_lock_); | 609 AutoSchedulerLock auto_lock(idle_workers_stack_lock_); |
| 610 idle_workers_stack_.Remove(worker); | 610 idle_workers_stack_.Remove(worker); |
| 611 } | 611 } |
| 612 | 612 |
| 613 bool SchedulerWorkerPoolImpl::CanWorkerDetachForTesting() { | 613 bool SchedulerWorkerPoolImpl::CanWorkerDetachForTesting() { |
| 614 return !worker_detachment_disallowed_.IsSet(); | 614 return !worker_detachment_disallowed_.IsSet(); |
| 615 } | 615 } |
| 616 | 616 |
| 617 } // namespace internal | 617 } // namespace internal |
| 618 } // namespace base | 618 } // namespace base |
| OLD | NEW |