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

Side by Side Diff: components/scheduler/base/task_queue_manager.h

Issue 1898233002: Report expected task queueing time via UMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: RenderSchedulerImpl owns all the things. Created 4 years, 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 CONTENT_RENDERER_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ 5 #ifndef CONTENT_RENDERER_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_
6 #define CONTENT_RENDERER_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ 6 #define CONTENT_RENDERER_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/atomic_sequence_num.h" 10 #include "base/atomic_sequence_num.h"
(...skipping 20 matching lines...) Expand all
31 31
32 namespace scheduler { 32 namespace scheduler {
33 namespace internal { 33 namespace internal {
34 class TaskQueueImpl; 34 class TaskQueueImpl;
35 } // namespace internal 35 } // namespace internal
36 36
37 class LazyNow; 37 class LazyNow;
38 class RealTimeDomain; 38 class RealTimeDomain;
39 class TimeDomain; 39 class TimeDomain;
40 class TaskQueueManagerDelegate; 40 class TaskQueueManagerDelegate;
41 class TaskTimeTracker;
41 42
42 // The task queue manager provides N task queues and a selector interface for 43 // The task queue manager provides N task queues and a selector interface for
43 // choosing which task queue to service next. Each task queue consists of two 44 // choosing which task queue to service next. Each task queue consists of two
44 // sub queues: 45 // sub queues:
45 // 46 //
46 // 1. Incoming task queue. Tasks that are posted get immediately appended here. 47 // 1. Incoming task queue. Tasks that are posted get immediately appended here.
47 // When a task is appended into an empty incoming queue, the task manager 48 // When a task is appended into an empty incoming queue, the task manager
48 // work function (DoWork) is scheduled to run on the main task runner. 49 // work function (DoWork) is scheduled to run on the main task runner.
49 // 50 //
50 // 2. Work queue. If a work queue is empty when DoWork() is entered, tasks from 51 // 2. Work queue. If a work queue is empty when DoWork() is entered, tasks from
(...skipping 24 matching lines...) Expand all
75 void MaybeScheduleDelayedWork(const tracked_objects::Location& from_here, 76 void MaybeScheduleDelayedWork(const tracked_objects::Location& from_here,
76 base::TimeTicks now, 77 base::TimeTicks now,
77 base::TimeDelta delay); 78 base::TimeDelta delay);
78 79
79 // Set the number of tasks executed in a single invocation of the task queue 80 // Set the number of tasks executed in a single invocation of the task queue
80 // manager. Increasing the batch size can reduce the overhead of yielding 81 // manager. Increasing the batch size can reduce the overhead of yielding
81 // back to the main message loop -- at the cost of potentially delaying other 82 // back to the main message loop -- at the cost of potentially delaying other
82 // tasks posted to the main loop. The batch size is 1 by default. 83 // tasks posted to the main loop. The batch size is 1 by default.
83 void SetWorkBatchSize(int work_batch_size); 84 void SetWorkBatchSize(int work_batch_size);
84 85
86 void SetTaskTimeTracker(TaskTimeTracker* task_time_tracker) {
alex clarke (OOO till 29th) 2016/07/06 09:51:39 Please add a brief comment explaining what happens
tdresser 2016/07/06 13:25:34 Done.
87 task_time_tracker_ = task_time_tracker;
88 }
89
85 // These functions can only be called on the same thread that the task queue 90 // These functions can only be called on the same thread that the task queue
86 // manager executes its tasks on. 91 // manager executes its tasks on.
87 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer); 92 void AddTaskObserver(base::MessageLoop::TaskObserver* task_observer);
88 void RemoveTaskObserver(base::MessageLoop::TaskObserver* task_observer); 93 void RemoveTaskObserver(base::MessageLoop::TaskObserver* task_observer);
89 94
90 // Returns true if any task from a monitored task queue was was run since the 95 // Returns true if any task from a monitored task queue was was run since the
91 // last call to GetAndClearSystemIsQuiescentBit. 96 // last call to GetAndClearSystemIsQuiescentBit.
92 bool GetAndClearSystemIsQuiescentBit(); 97 bool GetAndClearSystemIsQuiescentBit();
93 98
94 // Creates a task queue with the given |spec|. Must be called on the thread 99 // Creates a task queue with the given |spec|. Must be called on the thread
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 165
161 // Use the selector to choose a pending task and run it. 166 // Use the selector to choose a pending task and run it.
162 void DoWork(base::TimeTicks run_time, bool from_main_thread); 167 void DoWork(base::TimeTicks run_time, bool from_main_thread);
163 168
164 // Delayed Tasks with run_times <= Now() are enqueued onto the work queue. 169 // Delayed Tasks with run_times <= Now() are enqueued onto the work queue.
165 // Reloads any empty work queues which have automatic pumping enabled and 170 // Reloads any empty work queues which have automatic pumping enabled and
166 // which are eligible to be auto pumped based on the |previous_task| which was 171 // which are eligible to be auto pumped based on the |previous_task| which was
167 // run and |should_trigger_wakeup|. Call with an empty |previous_task| if no 172 // run and |should_trigger_wakeup|. Call with an empty |previous_task| if no
168 // task was just run. 173 // task was just run.
169 void UpdateWorkQueues(bool should_trigger_wakeup, 174 void UpdateWorkQueues(bool should_trigger_wakeup,
170 const internal::TaskQueueImpl::Task* previous_task); 175 const internal::TaskQueueImpl::Task* previous_task,
176 LazyNow lazy_now);
171 177
172 // Chooses the next work queue to service. Returns true if |out_queue| 178 // Chooses the next work queue to service. Returns true if |out_queue|
173 // indicates the queue from which the next task should be run, false to 179 // indicates the queue from which the next task should be run, false to
174 // avoid running any tasks. 180 // avoid running any tasks.
175 bool SelectWorkQueueToService(internal::WorkQueue** out_work_queue); 181 bool SelectWorkQueueToService(internal::WorkQueue** out_work_queue);
176 182
177 // Runs a single nestable task from the |queue|. On exit, |out_task| will 183 // Runs a single nestable task from the |queue|. On exit, |out_task| will
178 // contain the task which was executed. Non-nestable task are reposted on the 184 // contain the task which was executed. Non-nestable task are reposted on the
179 // run loop. The queue must not be empty. 185 // run loop. The queue must not be empty.
180 enum class ProcessTaskResult { 186 enum class ProcessTaskResult {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 225
220 base::ThreadChecker main_thread_checker_; 226 base::ThreadChecker main_thread_checker_;
221 scoped_refptr<TaskQueueManagerDelegate> delegate_; 227 scoped_refptr<TaskQueueManagerDelegate> delegate_;
222 internal::TaskQueueSelector selector_; 228 internal::TaskQueueSelector selector_;
223 229
224 base::Closure from_main_thread_immediate_do_work_closure_; 230 base::Closure from_main_thread_immediate_do_work_closure_;
225 base::Closure from_other_thread_immediate_do_work_closure_; 231 base::Closure from_other_thread_immediate_do_work_closure_;
226 232
227 bool task_was_run_on_quiescence_monitored_queue_; 233 bool task_was_run_on_quiescence_monitored_queue_;
228 234
229 // To reduce locking overhead we track pending calls to DoWork seperatly for 235 // To reduce locking overhead we track pending calls to DoWork seperately for
Sami 2016/07/06 10:08:29 typo: separately :)
tdresser 2016/07/06 13:25:34 Done.
230 // the main thread and other threads. 236 // the main thread and other threads.
231 std::set<base::TimeTicks> main_thread_pending_wakeups_; 237 std::set<base::TimeTicks> main_thread_pending_wakeups_;
232 238
233 // Protects |other_thread_pending_wakeups_|. 239 // Protects |other_thread_pending_wakeups_|.
234 mutable base::Lock other_thread_lock_; 240 mutable base::Lock other_thread_lock_;
235 std::set<base::TimeTicks> other_thread_pending_wakeups_; 241 std::set<base::TimeTicks> other_thread_pending_wakeups_;
236 242
237 int work_batch_size_; 243 int work_batch_size_;
238 size_t task_count_; 244 size_t task_count_;
239 245
240 base::ObserverList<base::MessageLoop::TaskObserver> task_observers_; 246 base::ObserverList<base::MessageLoop::TaskObserver> task_observers_;
241 247
248 TaskTimeTracker* task_time_tracker_; // NOT OWNED
249
242 const char* tracing_category_; 250 const char* tracing_category_;
243 const char* disabled_by_default_tracing_category_; 251 const char* disabled_by_default_tracing_category_;
244 const char* disabled_by_default_verbose_tracing_category_; 252 const char* disabled_by_default_verbose_tracing_category_;
245 253
246 internal::TaskQueueImpl* currently_executing_task_queue_; // NOT OWNED 254 internal::TaskQueueImpl* currently_executing_task_queue_; // NOT OWNED
247 255
248 Observer* observer_; // NOT OWNED 256 Observer* observer_; // NOT OWNED
249 scoped_refptr<DeletionSentinel> deletion_sentinel_; 257 scoped_refptr<DeletionSentinel> deletion_sentinel_;
250 base::WeakPtrFactory<TaskQueueManager> weak_factory_; 258 base::WeakPtrFactory<TaskQueueManager> weak_factory_;
251 259
252 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); 260 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager);
253 }; 261 };
254 262
255 } // namespace scheduler 263 } // namespace scheduler
256 264
257 #endif // CONTENT_RENDERER_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ 265 #endif // CONTENT_RENDERER_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698