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. | |
fdoray
2016/11/15 15:27:02
// The return value may not be accurate if workers
robliao
2016/11/15 15:57:19
Done.
| |
110 size_t NumberOfAliveWorkersForTesting(); | |
111 | |
109 private: | 112 private: |
110 class SchedulerSingleThreadTaskRunner; | 113 class SchedulerSingleThreadTaskRunner; |
111 class SchedulerWorkerDelegateImpl; | 114 class SchedulerWorkerDelegateImpl; |
112 | 115 |
113 SchedulerWorkerPoolImpl(StringPiece name, | 116 SchedulerWorkerPoolImpl(StringPiece name, |
114 SchedulerWorkerPoolParams::IORestriction | 117 SchedulerWorkerPoolParams::IORestriction |
115 io_restriction, | 118 io_restriction, |
116 const TimeDelta& suggested_reclaim_time, | 119 const TimeDelta& suggested_reclaim_time, |
117 TaskTracker* task_tracker, | 120 TaskTracker* task_tracker, |
118 DelayedTaskManager* delayed_task_manager); | 121 DelayedTaskManager* delayed_task_manager); |
119 | 122 |
120 bool Initialize( | 123 bool Initialize( |
121 ThreadPriority priority_hint, | 124 ThreadPriority priority_hint, |
125 SchedulerWorkerPoolParams::StandbyThreadPolicy standby_thread_policy, | |
122 size_t max_threads, | 126 size_t max_threads, |
123 const ReEnqueueSequenceCallback& re_enqueue_sequence_callback); | 127 const ReEnqueueSequenceCallback& re_enqueue_sequence_callback); |
124 | 128 |
125 // Wakes up |worker|. | 129 // Wakes up |worker|. |
126 void WakeUpWorker(SchedulerWorker* worker); | 130 void WakeUpWorker(SchedulerWorker* worker); |
127 | 131 |
128 // Wakes up the last worker from this worker pool to go idle, if any. | 132 // Wakes up the last worker from this worker pool to go idle, if any. |
129 void WakeUpOneWorker(); | 133 void WakeUpOneWorker(); |
130 | 134 |
131 // Adds |worker| to |idle_workers_stack_|. | 135 // Adds |worker| to |idle_workers_stack_|. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 TaskTracker* const task_tracker_; | 219 TaskTracker* const task_tracker_; |
216 DelayedTaskManager* const delayed_task_manager_; | 220 DelayedTaskManager* const delayed_task_manager_; |
217 | 221 |
218 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolImpl); | 222 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolImpl); |
219 }; | 223 }; |
220 | 224 |
221 } // namespace internal | 225 } // namespace internal |
222 } // namespace base | 226 } // namespace base |
223 | 227 |
224 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_ | 228 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_ |
OLD | NEW |