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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 void JoinForTesting(); | 99 void JoinForTesting(); |
100 | 100 |
101 // Disallows worker thread detachment. If the suggested reclaim time is not | 101 // Disallows worker thread detachment. If the suggested reclaim time is not |
102 // TimeDelta::Max(), then the test should call this before the detach code can | 102 // TimeDelta::Max(), then the test should call this before the detach code can |
103 // run. The safest place to do this is before the a set of work is dispatched | 103 // run. The safest place to do this is before the a set of work is dispatched |
104 // (the worker pool is idle and steady state) or before the last | 104 // (the worker pool is idle and steady state) or before the last |
105 // synchronization point for all workers (all threads are busy and can't be | 105 // synchronization point for all workers (all threads are busy and can't be |
106 // reclaimed). | 106 // reclaimed). |
107 void DisallowWorkerDetachmentForTesting(); | 107 void DisallowWorkerDetachmentForTesting(); |
108 | 108 |
| 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. |
| 111 size_t NumberOfAliveWorkersForTesting(); |
| 112 |
109 private: | 113 private: |
110 class SchedulerSingleThreadTaskRunner; | 114 class SchedulerSingleThreadTaskRunner; |
111 class SchedulerWorkerDelegateImpl; | 115 class SchedulerWorkerDelegateImpl; |
112 | 116 |
113 SchedulerWorkerPoolImpl(StringPiece name, | 117 SchedulerWorkerPoolImpl(StringPiece name, |
114 SchedulerWorkerPoolParams::IORestriction | 118 SchedulerWorkerPoolParams::IORestriction |
115 io_restriction, | 119 io_restriction, |
116 const TimeDelta& suggested_reclaim_time, | 120 const TimeDelta& suggested_reclaim_time, |
117 TaskTracker* task_tracker, | 121 TaskTracker* task_tracker, |
118 DelayedTaskManager* delayed_task_manager); | 122 DelayedTaskManager* delayed_task_manager); |
119 | 123 |
120 bool Initialize( | 124 bool Initialize( |
121 ThreadPriority priority_hint, | 125 ThreadPriority priority_hint, |
| 126 SchedulerWorkerPoolParams::StandbyThreadPolicy standby_thread_policy, |
122 size_t max_threads, | 127 size_t max_threads, |
123 const ReEnqueueSequenceCallback& re_enqueue_sequence_callback); | 128 const ReEnqueueSequenceCallback& re_enqueue_sequence_callback); |
124 | 129 |
125 // Wakes up |worker|. | 130 // Wakes up |worker|. |
126 void WakeUpWorker(SchedulerWorker* worker); | 131 void WakeUpWorker(SchedulerWorker* worker); |
127 | 132 |
128 // Wakes up the last worker from this worker pool to go idle, if any. | 133 // Wakes up the last worker from this worker pool to go idle, if any. |
129 void WakeUpOneWorker(); | 134 void WakeUpOneWorker(); |
130 | 135 |
131 // Adds |worker| to |idle_workers_stack_|. | 136 // Adds |worker| to |idle_workers_stack_|. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 TaskTracker* const task_tracker_; | 220 TaskTracker* const task_tracker_; |
216 DelayedTaskManager* const delayed_task_manager_; | 221 DelayedTaskManager* const delayed_task_manager_; |
217 | 222 |
218 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolImpl); | 223 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolImpl); |
219 }; | 224 }; |
220 | 225 |
221 } // namespace internal | 226 } // namespace internal |
222 } // namespace base | 227 } // namespace base |
223 | 228 |
224 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_ | 229 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_ |
OLD | NEW |