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

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

Issue 2504443002: Cleanup: Move SchedulerWorkerPoolImpl ForTesting Methods to the Bottom of the Public Section (Closed)
Patch Set: Clang Format Is Now Enforced in Base Created 4 years, 1 month 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
« no previous file with comments | « no previous file | base/task_scheduler/scheduler_worker_pool_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 // worker of this worker pool tries to run a Task. |task_tracker| is used to 58 // worker of this worker pool tries to run a Task. |task_tracker| is used to
59 // handle shutdown behavior of Tasks. |delayed_task_manager| handles Tasks 59 // handle shutdown behavior of Tasks. |delayed_task_manager| handles Tasks
60 // posted with a delay. Returns nullptr on failure to create a worker pool 60 // posted with a delay. Returns nullptr on failure to create a worker pool
61 // with at least one thread. 61 // with at least one thread.
62 static std::unique_ptr<SchedulerWorkerPoolImpl> Create( 62 static std::unique_ptr<SchedulerWorkerPoolImpl> Create(
63 const SchedulerWorkerPoolParams& params, 63 const SchedulerWorkerPoolParams& params,
64 const ReEnqueueSequenceCallback& re_enqueue_sequence_callback, 64 const ReEnqueueSequenceCallback& re_enqueue_sequence_callback,
65 TaskTracker* task_tracker, 65 TaskTracker* task_tracker,
66 DelayedTaskManager* delayed_task_manager); 66 DelayedTaskManager* delayed_task_manager);
67 67
68 // Waits until all workers are idle.
69 void WaitForAllWorkersIdleForTesting();
70
71 // Joins all workers of this worker pool. Tasks that are already running are
72 // allowed to complete their execution. This can only be called once.
73 void JoinForTesting();
74
75 // Disallows worker thread detachment. If the suggested reclaim time is not
76 // TimeDelta::Max(), then the test should call this before the detach code can
77 // run. The safest place to do this is before the a set of work is dispatched
78 // (the worker pool is idle and steady state) or before the last
79 // synchronization point for all workers (all threads are busy and can't be
80 // reclaimed).
81 void DisallowWorkerDetachmentForTesting();
82
83 // SchedulerWorkerPool: 68 // SchedulerWorkerPool:
84 scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits( 69 scoped_refptr<TaskRunner> CreateTaskRunnerWithTraits(
85 const TaskTraits& traits) override; 70 const TaskTraits& traits) override;
86 scoped_refptr<SequencedTaskRunner> CreateSequencedTaskRunnerWithTraits( 71 scoped_refptr<SequencedTaskRunner> CreateSequencedTaskRunnerWithTraits(
87 const TaskTraits& traits) override; 72 const TaskTraits& traits) override;
88 scoped_refptr<SingleThreadTaskRunner> CreateSingleThreadTaskRunnerWithTraits( 73 scoped_refptr<SingleThreadTaskRunner> CreateSingleThreadTaskRunnerWithTraits(
89 const TaskTraits& traits) override; 74 const TaskTraits& traits) override;
90 void ReEnqueueSequence(scoped_refptr<Sequence> sequence, 75 void ReEnqueueSequence(scoped_refptr<Sequence> sequence,
91 const SequenceSortKey& sequence_sort_key) override; 76 const SequenceSortKey& sequence_sort_key) override;
92 bool PostTaskWithSequence(std::unique_ptr<Task> task, 77 bool PostTaskWithSequence(std::unique_ptr<Task> task,
93 scoped_refptr<Sequence> sequence, 78 scoped_refptr<Sequence> sequence,
94 SchedulerWorker* worker) override; 79 SchedulerWorker* worker) override;
95 void PostTaskWithSequenceNow(std::unique_ptr<Task> task, 80 void PostTaskWithSequenceNow(std::unique_ptr<Task> task,
96 scoped_refptr<Sequence> sequence, 81 scoped_refptr<Sequence> sequence,
97 SchedulerWorker* worker) override; 82 SchedulerWorker* worker) override;
98 83
99 const HistogramBase* num_tasks_before_detach_histogram() const { 84 const HistogramBase* num_tasks_before_detach_histogram() const {
100 return num_tasks_before_detach_histogram_; 85 return num_tasks_before_detach_histogram_;
101 } 86 }
102 87
103 const HistogramBase* num_tasks_between_waits_histogram() const { 88 const HistogramBase* num_tasks_between_waits_histogram() const {
104 return num_tasks_between_waits_histogram_; 89 return num_tasks_between_waits_histogram_;
105 } 90 }
106 91
107 void GetHistograms(std::vector<const HistogramBase*>* histograms) const; 92 void GetHistograms(std::vector<const HistogramBase*>* histograms) const;
108 93
94 // Waits until all workers are idle.
95 void WaitForAllWorkersIdleForTesting();
96
97 // Joins all workers of this worker pool. Tasks that are already running are
98 // allowed to complete their execution. This can only be called once.
99 void JoinForTesting();
100
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
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
105 // synchronization point for all workers (all threads are busy and can't be
106 // reclaimed).
107 void DisallowWorkerDetachmentForTesting();
108
109 private: 109 private:
110 class SchedulerSingleThreadTaskRunner; 110 class SchedulerSingleThreadTaskRunner;
111 class SchedulerWorkerDelegateImpl; 111 class SchedulerWorkerDelegateImpl;
112 112
113 SchedulerWorkerPoolImpl(StringPiece name, 113 SchedulerWorkerPoolImpl(StringPiece name,
114 SchedulerWorkerPoolParams::IORestriction 114 SchedulerWorkerPoolParams::IORestriction
115 io_restriction, 115 io_restriction,
116 const TimeDelta& suggested_reclaim_time, 116 const TimeDelta& suggested_reclaim_time,
117 TaskTracker* task_tracker, 117 TaskTracker* task_tracker,
118 DelayedTaskManager* delayed_task_manager); 118 DelayedTaskManager* delayed_task_manager);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 TaskTracker* const task_tracker_; 215 TaskTracker* const task_tracker_;
216 DelayedTaskManager* const delayed_task_manager_; 216 DelayedTaskManager* const delayed_task_manager_;
217 217
218 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolImpl); 218 DISALLOW_COPY_AND_ASSIGN(SchedulerWorkerPoolImpl);
219 }; 219 };
220 220
221 } // namespace internal 221 } // namespace internal
222 } // namespace base 222 } // namespace base
223 223
224 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_ 224 #endif // BASE_TASK_SCHEDULER_SCHEDULER_WORKER_POOL_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | base/task_scheduler/scheduler_worker_pool_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698