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

Side by Side Diff: base/task_scheduler/scheduler_worker_pool_impl.cc

Issue 2809163003: Always use TaskScheduler::InitParams to initialize a TaskScheduler. (Closed)
Patch Set: CR-gab-robliao-17-18 Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698