| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 void GetHistograms(std::vector<const HistogramBase*>* histograms) const; | 91 void GetHistograms(std::vector<const HistogramBase*>* histograms) const; |
| 92 | 92 |
| 93 // Waits until all workers are idle. | 93 // Waits until all workers are idle. |
| 94 void WaitForAllWorkersIdleForTesting(); | 94 void WaitForAllWorkersIdleForTesting(); |
| 95 | 95 |
| 96 // Joins all workers of this worker pool. Tasks that are already running are | 96 // Joins all workers of this worker pool. Tasks that are already running are |
| 97 // allowed to complete their execution. This can only be called once. | 97 // allowed to complete their execution. This can only be called once. |
| 98 void JoinForTesting(); | 98 void JoinForTesting(); |
| 99 | 99 |
| 100 // Disallows worker thread detachment. If the suggested reclaim time is not | 100 // Disallows worker detachment. If the suggested reclaim time is not |
| 101 // TimeDelta::Max(), then the test should call this before the detach code can | 101 // TimeDelta::Max(), the test must call this before JoinForTesting() to reduce |
| 102 // run. The safest place to do this is before the a set of work is dispatched | 102 // the chance of thread detachment during the process of joining all of the |
| 103 // (the worker pool is idle and steady state) or before the last | 103 // threads, and as a result, threads running after JoinForTesting(). |
| 104 // synchronization point for all workers (all threads are busy and can't be | |
| 105 // reclaimed). | |
| 106 void DisallowWorkerDetachmentForTesting(); | 104 void DisallowWorkerDetachmentForTesting(); |
| 107 | 105 |
| 108 // Returns the number of workers alive in this worker pool. The value may | 106 // Returns the number of workers alive in this worker pool. The value may |
| 109 // change if workers are woken up or detached during this call. | 107 // change if workers are woken up or detached during this call. |
| 110 size_t NumberOfAliveWorkersForTesting(); | 108 size_t NumberOfAliveWorkersForTesting(); |
| 111 | 109 |
| 112 private: | 110 private: |
| 113 class SchedulerSingleThreadTaskRunner; | 111 class SchedulerSingleThreadTaskRunner; |
| 114 class SchedulerWorkerDelegateImpl; | 112 class SchedulerWorkerDelegateImpl; |
| 115 | 113 |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 TaskTracker* const task_tracker_; | 204 TaskTracker* const task_tracker_; |
| 207 DelayedTaskManager* const delayed_task_manager_; | 205 DelayedTaskManager* const delayed_task_manager_; |
| 208 | 206 |
| 209 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolImpl); | 207 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolImpl); |
| 210 }; | 208 }; |
| 211 | 209 |
| 212 } // namespace internal | 210 } // namespace internal |
| 213 } // namespace base | 211 } // namespace base |
| 214 | 212 |
| 215 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_ | 213 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_ |
| OLD | NEW |