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

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

Issue 1432263002: (reland) Adds TimeDomains to the TaskQueueManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 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
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 16 matching lines...) Expand all
27 class TracedValue; 27 class TracedValue;
28 } // namespace trace_event 28 } // namespace trace_event
29 } // namespace base 29 } // namespace base
30 30
31 namespace scheduler { 31 namespace scheduler {
32 namespace internal { 32 namespace internal {
33 class LazyNow; 33 class LazyNow;
34 class TaskQueueImpl; 34 class TaskQueueImpl;
35 } // namespace internal 35 } // namespace internal
36 36
37 class DelayedTaskDelegate;
37 class TaskQueueManagerDelegate; 38 class TaskQueueManagerDelegate;
38 39
39 // The task queue manager provides N task queues and a selector interface for 40 // The task queue manager provides N task queues and a selector interface for
40 // choosing which task queue to service next. Each task queue consists of two 41 // choosing which task queue to service next. Each task queue consists of two
41 // sub queues: 42 // sub queues:
42 // 43 //
43 // 1. Incoming task queue. Tasks that are posted get immediately appended here. 44 // 1. Incoming task queue. Tasks that are posted get immediately appended here.
44 // When a task is appended into an empty incoming queue, the task manager 45 // When a task is appended into an empty incoming queue, the task manager
45 // work function (DoWork) is scheduled to run on the main task runner. 46 // work function (DoWork) is scheduled to run on the main task runner.
46 // 47 //
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 internal::TaskQueueImpl* selected_queue) const; 172 internal::TaskQueueImpl* selected_queue) const;
172 173
173 // Causes DoWork to start calling UpdateWorkQueue for |queue|. Can be called 174 // Causes DoWork to start calling UpdateWorkQueue for |queue|. Can be called
174 // from any thread. 175 // from any thread.
175 void RegisterAsUpdatableTaskQueue(internal::TaskQueueImpl* queue); 176 void RegisterAsUpdatableTaskQueue(internal::TaskQueueImpl* queue);
176 177
177 // Prevents DoWork from calling UpdateWorkQueue for |queue|. Must be called 178 // Prevents DoWork from calling UpdateWorkQueue for |queue|. Must be called
178 // from the thread the TaskQueueManager was created on. 179 // from the thread the TaskQueueManager was created on.
179 void UnregisterAsUpdatableTaskQueue(internal::TaskQueueImpl* queue); 180 void UnregisterAsUpdatableTaskQueue(internal::TaskQueueImpl* queue);
180 181
181 // Schedule a call to DoWork at |delayed_run_time| which indirectly calls
182 // TaskQueueImpl::MoveReadyDelayedTasksToIncomingQueue for |queue|.
183 // Can be called from any thread.
184 void ScheduleDelayedWork(internal::TaskQueueImpl* queue,
185 base::TimeTicks delayed_run_time,
186 internal::LazyNow* lazy_now);
187
188 // Function calling ScheduleDelayedWork that's suitable for use in base::Bind.
189 void ScheduleDelayedWorkTask(scoped_refptr<internal::TaskQueueImpl> queue,
190 base::TimeTicks delayed_run_time);
191
192 // Call TaskQueueImpl::MoveReadyDelayedTasksToIncomingQueue for each
193 // registered queue for which the delay has elapsed.
194 void WakeupReadyDelayedQueues(internal::LazyNow* lazy_now);
195
196 void MoveNewlyUpdatableQueuesIntoUpdatableQueueSet(); 182 void MoveNewlyUpdatableQueuesIntoUpdatableQueueSet();
197 183
198 std::set<scoped_refptr<internal::TaskQueueImpl>> queues_; 184 std::set<scoped_refptr<internal::TaskQueueImpl>> queues_;
199 185
200 // We have to be careful when deleting a queue because some of the code uses 186 // We have to be careful when deleting a queue because some of the code uses
201 // raw pointers and doesn't expect the rug to be pulled out from underneath. 187 // raw pointers and doesn't expect the rug to be pulled out from underneath.
202 std::set<scoped_refptr<internal::TaskQueueImpl>> queues_to_delete_; 188 std::set<scoped_refptr<internal::TaskQueueImpl>> queues_to_delete_;
203 189
204 // This lock guards only |newly_updatable_|. It's not expected to be heavily 190 // This lock guards only |newly_updatable_|. It's not expected to be heavily
205 // contended. 191 // contended.
206 base::Lock newly_updatable_lock_; 192 base::Lock newly_updatable_lock_;
207 std::vector<internal::TaskQueueImpl*> newly_updatable_; 193 std::vector<internal::TaskQueueImpl*> newly_updatable_;
208 194
209 // Set of task queues with avaliable work on the incoming queue. This should 195 // Set of task queues with avaliable work on the incoming queue. This should
210 // only be accessed from the main thread. 196 // only be accessed from the main thread.
211 std::set<internal::TaskQueueImpl*> updatable_queue_set_; 197 std::set<internal::TaskQueueImpl*> updatable_queue_set_;
212 198
213 typedef std::multimap<base::TimeTicks, internal::TaskQueueImpl*>
214 DelayedWakeupMultimap;
215
216 DelayedWakeupMultimap delayed_wakeup_multimap_;
217
218 base::AtomicSequenceNumber task_sequence_num_; 199 base::AtomicSequenceNumber task_sequence_num_;
219 base::debug::TaskAnnotator task_annotator_; 200 base::debug::TaskAnnotator task_annotator_;
220 201
221 base::ThreadChecker main_thread_checker_; 202 base::ThreadChecker main_thread_checker_;
222 scoped_refptr<TaskQueueManagerDelegate> delegate_; 203 scoped_refptr<TaskQueueManagerDelegate> delegate_;
223 internal::TaskQueueSelector selector_; 204 internal::TaskQueueSelector selector_;
224 205
225 base::Closure decrement_pending_and_do_work_closure_; 206 base::Closure decrement_pending_and_do_work_closure_;
226 base::Closure do_work_closure_; 207 base::Closure do_work_closure_;
227 208
228 bool task_was_run_on_quiescence_monitored_queue_; 209 bool task_was_run_on_quiescence_monitored_queue_;
229 210
230 // The pending_dowork_count_ is only tracked on the main thread since that's 211 // The pending_dowork_count_ is only tracked on the main thread since that's
231 // where re-entrant problems happen. 212 // where re-entrant problems happen.
232 int pending_dowork_count_; 213 int pending_dowork_count_;
233 214
234 int work_batch_size_; 215 int work_batch_size_;
235 216
236 base::ObserverList<base::MessageLoop::TaskObserver> task_observers_; 217 base::ObserverList<base::MessageLoop::TaskObserver> task_observers_;
237 218
238 const char* tracing_category_; 219 const char* tracing_category_;
239 const char* disabled_by_default_tracing_category_; 220 const char* disabled_by_default_tracing_category_;
240 const char* disabled_by_default_verbose_tracing_category_; 221 const char* disabled_by_default_verbose_tracing_category_;
241 222
242 Observer* observer_; // NOT OWNED 223 Observer* observer_; // NOT OWNED
243 scoped_refptr<DeletionSentinel> deletion_sentinel_; 224 scoped_refptr<DeletionSentinel> deletion_sentinel_;
225 scoped_refptr<DelayedTaskDelegate> delayed_task_delegate_;
244 base::WeakPtrFactory<TaskQueueManager> weak_factory_; 226 base::WeakPtrFactory<TaskQueueManager> weak_factory_;
245 227
246 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); 228 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager);
247 }; 229 };
248 230
249 } // namespace scheduler 231 } // namespace scheduler
250 232
251 #endif // CONTENT_RENDERER_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ 233 #endif // CONTENT_RENDERER_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698