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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 DCHECK(!CanWorkerDetachForTesting() || suggested_reclaim_time_.is_max()) << | 271 DCHECK(!CanWorkerDetachForTesting() || suggested_reclaim_time_.is_max()) << |
272 "Workers can detach during join."; | 272 "Workers can detach during join."; |
273 for (const auto& worker : workers_) | 273 for (const auto& worker : workers_) |
274 worker->JoinForTesting(); | 274 worker->JoinForTesting(); |
275 | 275 |
276 DCHECK(!join_for_testing_returned_.IsSignaled()); | 276 DCHECK(!join_for_testing_returned_.IsSignaled()); |
277 join_for_testing_returned_.Signal(); | 277 join_for_testing_returned_.Signal(); |
278 } | 278 } |
279 | 279 |
280 void SchedulerWorkerPoolImpl::DisallowWorkerDetachmentForTesting() { | 280 void SchedulerWorkerPoolImpl::DisallowWorkerDetachmentForTesting() { |
281 AutoSchedulerLock auto_lock(worker_detachment_allowed_lock_); | 281 worker_detachment_disallowed_.Set(); |
282 worker_detachment_allowed_ = false; | |
283 } | 282 } |
284 | 283 |
285 scoped_refptr<TaskRunner> SchedulerWorkerPoolImpl::CreateTaskRunnerWithTraits( | 284 scoped_refptr<TaskRunner> SchedulerWorkerPoolImpl::CreateTaskRunnerWithTraits( |
286 const TaskTraits& traits, | 285 const TaskTraits& traits, |
287 ExecutionMode execution_mode) { | 286 ExecutionMode execution_mode) { |
288 switch (execution_mode) { | 287 switch (execution_mode) { |
289 case ExecutionMode::PARALLEL: | 288 case ExecutionMode::PARALLEL: |
290 return make_scoped_refptr(new SchedulerParallelTaskRunner(traits, this)); | 289 return make_scoped_refptr(new SchedulerParallelTaskRunner(traits, this)); |
291 | 290 |
292 case ExecutionMode::SEQUENCED: | 291 case ExecutionMode::SEQUENCED: |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 return idle_workers_stack_.Peek(); | 630 return idle_workers_stack_.Peek(); |
632 } | 631 } |
633 | 632 |
634 void SchedulerWorkerPoolImpl::RemoveFromIdleWorkersStack( | 633 void SchedulerWorkerPoolImpl::RemoveFromIdleWorkersStack( |
635 SchedulerWorker* worker) { | 634 SchedulerWorker* worker) { |
636 AutoSchedulerLock auto_lock(idle_workers_stack_lock_); | 635 AutoSchedulerLock auto_lock(idle_workers_stack_lock_); |
637 idle_workers_stack_.Remove(worker); | 636 idle_workers_stack_.Remove(worker); |
638 } | 637 } |
639 | 638 |
640 bool SchedulerWorkerPoolImpl::CanWorkerDetachForTesting() { | 639 bool SchedulerWorkerPoolImpl::CanWorkerDetachForTesting() { |
641 AutoSchedulerLock auto_lock(worker_detachment_allowed_lock_); | 640 return !worker_detachment_disallowed_.IsSet(); |
642 return worker_detachment_allowed_; | |
643 } | 641 } |
644 | 642 |
645 } // namespace internal | 643 } // namespace internal |
646 } // namespace base | 644 } // namespace base |
OLD | NEW |