| 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> |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 108 |
| 109 // Returns the number of workers alive in this worker pool. The value may | 109 // Returns the number of workers alive in this worker pool. The value may |
| 110 // change if workers are woken up or detached during this call. | 110 // change if workers are woken up or detached during this call. |
| 111 size_t NumberOfAliveWorkersForTesting(); | 111 size_t NumberOfAliveWorkersForTesting(); |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 class SchedulerSingleThreadTaskRunner; | 114 class SchedulerSingleThreadTaskRunner; |
| 115 class SchedulerWorkerDelegateImpl; | 115 class SchedulerWorkerDelegateImpl; |
| 116 | 116 |
| 117 SchedulerWorkerPoolImpl(StringPiece name, | 117 SchedulerWorkerPoolImpl(StringPiece name, |
| 118 SchedulerWorkerPoolParams::IORestriction | |
| 119 io_restriction, | |
| 120 const TimeDelta& suggested_reclaim_time, | 118 const TimeDelta& suggested_reclaim_time, |
| 121 TaskTracker* task_tracker, | 119 TaskTracker* task_tracker, |
| 122 DelayedTaskManager* delayed_task_manager); | 120 DelayedTaskManager* delayed_task_manager); |
| 123 | 121 |
| 124 bool Initialize( | 122 bool Initialize( |
| 125 ThreadPriority priority_hint, | 123 ThreadPriority priority_hint, |
| 126 SchedulerWorkerPoolParams::StandbyThreadPolicy standby_thread_policy, | 124 SchedulerWorkerPoolParams::StandbyThreadPolicy standby_thread_policy, |
| 127 size_t max_threads, | 125 size_t max_threads, |
| 128 const ReEnqueueSequenceCallback& re_enqueue_sequence_callback); | 126 const ReEnqueueSequenceCallback& re_enqueue_sequence_callback); |
| 129 | 127 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 155 // Synchronizes access to |next_worker_index_|. | 153 // Synchronizes access to |next_worker_index_|. |
| 156 SchedulerLock next_worker_index_lock_; | 154 SchedulerLock next_worker_index_lock_; |
| 157 | 155 |
| 158 // Index of the worker that will be assigned to the next single-threaded | 156 // Index of the worker that will be assigned to the next single-threaded |
| 159 // TaskRunner returned by this pool. | 157 // TaskRunner returned by this pool. |
| 160 size_t next_worker_index_ = 0; | 158 size_t next_worker_index_ = 0; |
| 161 | 159 |
| 162 // PriorityQueue from which all threads of this worker pool get work. | 160 // PriorityQueue from which all threads of this worker pool get work. |
| 163 PriorityQueue shared_priority_queue_; | 161 PriorityQueue shared_priority_queue_; |
| 164 | 162 |
| 165 // Indicates whether Tasks on this worker pool are allowed to make I/O calls. | |
| 166 const SchedulerWorkerPoolParams::IORestriction io_restriction_; | |
| 167 | |
| 168 // Suggested reclaim time for workers. | 163 // Suggested reclaim time for workers. |
| 169 const TimeDelta suggested_reclaim_time_; | 164 const TimeDelta suggested_reclaim_time_; |
| 170 | 165 |
| 171 // Synchronizes access to |idle_workers_stack_| and | 166 // Synchronizes access to |idle_workers_stack_| and |
| 172 // |idle_workers_stack_cv_for_testing_|. Has |shared_priority_queue_|'s | 167 // |idle_workers_stack_cv_for_testing_|. Has |shared_priority_queue_|'s |
| 173 // lock as its predecessor so that a worker can be pushed to | 168 // lock as its predecessor so that a worker can be pushed to |
| 174 // |idle_workers_stack_| within the scope of a Transaction (more | 169 // |idle_workers_stack_| within the scope of a Transaction (more |
| 175 // details in GetWork()). | 170 // details in GetWork()). |
| 176 mutable SchedulerLock idle_workers_stack_lock_; | 171 mutable SchedulerLock idle_workers_stack_lock_; |
| 177 | 172 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 TaskTracker* const task_tracker_; | 215 TaskTracker* const task_tracker_; |
| 221 DelayedTaskManager* const delayed_task_manager_; | 216 DelayedTaskManager* const delayed_task_manager_; |
| 222 | 217 |
| 223 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolImpl); | 218 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolImpl); |
| 224 }; | 219 }; |
| 225 | 220 |
| 226 } // namespace internal | 221 } // namespace internal |
| 227 } // namespace base | 222 } // namespace base |
| 228 | 223 |
| 229 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_ | 224 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_ |
| OLD | NEW |