| 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 #ifndef BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_ | 5 #ifndef BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_ |
| 6 #define BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_ | 6 #define BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/base_export.h" | 14 #include "base/base_export.h" |
| 15 #include "base/callback.h" | 15 #include "base/callback.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
| 19 #include "base/strings/string_piece.h" | 19 #include "base/strings/string_piece.h" |
| 20 #include "base/synchronization/atomic_flag.h" |
| 20 #include "base/synchronization/condition_variable.h" | 21 #include "base/synchronization/condition_variable.h" |
| 21 #include "base/task_runner.h" | 22 #include "base/task_runner.h" |
| 22 #include "base/task_scheduler/priority_queue.h" | 23 #include "base/task_scheduler/priority_queue.h" |
| 23 #include "base/task_scheduler/scheduler_lock.h" | 24 #include "base/task_scheduler/scheduler_lock.h" |
| 24 #include "base/task_scheduler/scheduler_worker.h" | 25 #include "base/task_scheduler/scheduler_worker.h" |
| 25 #include "base/task_scheduler/scheduler_worker_pool.h" | 26 #include "base/task_scheduler/scheduler_worker_pool.h" |
| 26 #include "base/task_scheduler/scheduler_worker_pool_params.h" | 27 #include "base/task_scheduler/scheduler_worker_pool_params.h" |
| 27 #include "base/task_scheduler/scheduler_worker_stack.h" | 28 #include "base/task_scheduler/scheduler_worker_stack.h" |
| 28 #include "base/task_scheduler/sequence.h" | 29 #include "base/task_scheduler/sequence.h" |
| 29 #include "base/task_scheduler/task.h" | 30 #include "base/task_scheduler/task.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 155 |
| 155 // Stack of idle workers. | 156 // Stack of idle workers. |
| 156 SchedulerWorkerStack idle_workers_stack_; | 157 SchedulerWorkerStack idle_workers_stack_; |
| 157 | 158 |
| 158 // Signaled when all workers become idle. | 159 // Signaled when all workers become idle. |
| 159 std::unique_ptr<ConditionVariable> idle_workers_stack_cv_for_testing_; | 160 std::unique_ptr<ConditionVariable> idle_workers_stack_cv_for_testing_; |
| 160 | 161 |
| 161 // Signaled once JoinForTesting() has returned. | 162 // Signaled once JoinForTesting() has returned. |
| 162 WaitableEvent join_for_testing_returned_; | 163 WaitableEvent join_for_testing_returned_; |
| 163 | 164 |
| 164 // Synchronizes access to |worker_detachment_allowed_|. | 165 // Indicates to the delegates that workers are not permitted to detach their |
| 165 SchedulerLock worker_detachment_allowed_lock_; | |
| 166 | |
| 167 // Indicates to the delegates that workers are permitted to detach their | |
| 168 // threads. | 166 // threads. |
| 169 bool worker_detachment_allowed_ = true; | 167 AtomicFlag worker_detachment_disallowed_; |
| 170 | 168 |
| 171 #if DCHECK_IS_ON() | 169 #if DCHECK_IS_ON() |
| 172 // Signaled when all workers have been created. | 170 // Signaled when all workers have been created. |
| 173 WaitableEvent workers_created_; | 171 WaitableEvent workers_created_; |
| 174 #endif | 172 #endif |
| 175 | 173 |
| 176 TaskTracker* const task_tracker_; | 174 TaskTracker* const task_tracker_; |
| 177 DelayedTaskManager* const delayed_task_manager_; | 175 DelayedTaskManager* const delayed_task_manager_; |
| 178 | 176 |
| 179 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolImpl); | 177 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolImpl); |
| 180 }; | 178 }; |
| 181 | 179 |
| 182 } // namespace internal | 180 } // namespace internal |
| 183 } // namespace base | 181 } // namespace base |
| 184 | 182 |
| 185 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_ | 183 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_ |
| OLD | NEW |