Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(778)

Side by Side Diff: base/task_scheduler/scheduler_worker_pool_impl.h

Issue 2628313004: Add TaskScheduler::JoinForTesting(). (Closed)
Patch Set: self-review Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(), then the test must call this before JoinForTesting() to
102 // run. The safest place to do this is before the a set of work is dispatched 102 // reduce the chances of having a thread that detaches itself before
robliao 2017/01/24 18:20:18 Possible revision: If the suggested reclaim time i
fdoray 2017/01/24 20:03:51 Done.
103 // (the worker pool is idle and steady state) or before the last 103 // JoinForTesting() is called but doesn't exit before JoinForTesting()
104 // synchronization point for all workers (all threads are busy and can't be 104 // returns.
105 // reclaimed).
106 void DisallowWorkerDetachmentForTesting(); 105 void DisallowWorkerDetachmentForTesting();
107 106
108 // Returns the number of workers alive in this worker pool. The value may 107 // 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. 108 // change if workers are woken up or detached during this call.
110 size_t NumberOfAliveWorkersForTesting(); 109 size_t NumberOfAliveWorkersForTesting();
111 110
112 private: 111 private:
113 class SchedulerSingleThreadTaskRunner; 112 class SchedulerSingleThreadTaskRunner;
114 class SchedulerWorkerDelegateImpl; 113 class SchedulerWorkerDelegateImpl;
115 114
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 TaskTracker* const task_tracker_; 205 TaskTracker* const task_tracker_;
207 DelayedTaskManager* const delayed_task_manager_; 206 DelayedTaskManager* const delayed_task_manager_;
208 207
209 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolImpl); 208 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolImpl);
210 }; 209 };
211 210
212 } // namespace internal 211 } // namespace internal
213 } // namespace base 212 } // namespace base
214 213
215 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_ 214 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698