| 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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 DCHECK(!workers_created_.IsSet()); | 248 DCHECK(!workers_created_.IsSet()); |
| 249 #endif | 249 #endif |
| 250 | 250 |
| 251 DCHECK(workers_.empty()); | 251 DCHECK(workers_.empty()); |
| 252 workers_.resize(params.max_threads()); | 252 workers_.resize(params.max_threads()); |
| 253 | 253 |
| 254 // Create workers in reverse order of index so that the worker with the | 254 // Create workers in reverse order of index so that the worker with the |
| 255 // highest index is at the bottom of the idle stack. | 255 // highest index is at the bottom of the idle stack. |
| 256 for (int index = params.max_threads() - 1; index >= 0; --index) { | 256 for (int index = params.max_threads() - 1; index >= 0; --index) { |
| 257 workers_[index] = make_scoped_refptr( | 257 workers_[index] = make_scoped_refptr( |
| 258 new SchedulerWorker(params.priority_hint(), | 258 new SchedulerWorker(priority_hint_, |
| 259 MakeUnique<SchedulerWorkerDelegateImpl>( | 259 MakeUnique<SchedulerWorkerDelegateImpl>( |
| 260 this, re_enqueue_sequence_callback_, index), | 260 this, re_enqueue_sequence_callback_, index), |
| 261 task_tracker_, params.backward_compatibility())); | 261 task_tracker_, params.backward_compatibility())); |
| 262 | 262 |
| 263 if (index >= num_wake_ups_before_start_) | 263 if (index >= num_wake_ups_before_start_) |
| 264 idle_workers_stack_.Push(workers_[index].get()); | 264 idle_workers_stack_.Push(workers_[index].get()); |
| 265 } | 265 } |
| 266 | 266 |
| 267 #if DCHECK_IS_ON() | 267 #if DCHECK_IS_ON() |
| 268 workers_created_.Set(); | 268 workers_created_.Set(); |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 602 AutoSchedulerLock auto_lock(idle_workers_stack_lock_); | 602 AutoSchedulerLock auto_lock(idle_workers_stack_lock_); |
| 603 idle_workers_stack_.Remove(worker); | 603 idle_workers_stack_.Remove(worker); |
| 604 } | 604 } |
| 605 | 605 |
| 606 bool SchedulerWorkerPoolImpl::CanWorkerDetachForTesting() { | 606 bool SchedulerWorkerPoolImpl::CanWorkerDetachForTesting() { |
| 607 return !worker_detachment_disallowed_.IsSet(); | 607 return !worker_detachment_disallowed_.IsSet(); |
| 608 } | 608 } |
| 609 | 609 |
| 610 } // namespace internal | 610 } // namespace internal |
| 611 } // namespace base | 611 } // namespace base |
| OLD | NEW |