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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/base/task_queue_manager.h

Issue 2653643002: Move has_incoming_immediate_work to the TaskQueueManager (Closed)
Patch Set: Don't try to be quite so clever in TaskQueueManager::ComputeDelayTillNextTask Created 3 years, 10 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 THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_H_ 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 void OnBeginNestedMessageLoop() override; 173 void OnBeginNestedMessageLoop() override;
174 174
175 // Called by the task queue to register a new pending task. 175 // Called by the task queue to register a new pending task.
176 void DidQueueTask(const internal::TaskQueueImpl::Task& pending_task); 176 void DidQueueTask(const internal::TaskQueueImpl::Task& pending_task);
177 177
178 // Use the selector to choose a pending task and run it. 178 // Use the selector to choose a pending task and run it.
179 void DoWork(base::TimeTicks run_time, bool from_main_thread); 179 void DoWork(base::TimeTicks run_time, bool from_main_thread);
180 180
181 // Delayed Tasks with run_times <= Now() are enqueued onto the work queue and 181 // Delayed Tasks with run_times <= Now() are enqueued onto the work queue and
182 // reloads any empty work queues. 182 // reloads any empty work queues.
183 void UpdateWorkQueues(LazyNow* lazy_now); 183 void WakeupReadyDelayedQueues(LazyNow* lazy_now);
184 184
185 // Chooses the next work queue to service. Returns true if |out_queue| 185 // Chooses the next work queue to service. Returns true if |out_queue|
186 // indicates the queue from which the next task should be run, false to 186 // indicates the queue from which the next task should be run, false to
187 // avoid running any tasks. 187 // avoid running any tasks.
188 bool SelectWorkQueueToService(internal::WorkQueue** out_work_queue); 188 bool SelectWorkQueueToService(internal::WorkQueue** out_work_queue);
189 189
190 enum class ProcessTaskResult { 190 enum class ProcessTaskResult {
191 DEFERRED, 191 DEFERRED,
192 EXECUTED, 192 EXECUTED,
193 TASK_QUEUE_MANAGER_DELETED 193 TASK_QUEUE_MANAGER_DELETED
(...skipping 21 matching lines...) Expand all
215 base::Optional<base::TimeDelta> ComputeDelayTillNextTask(LazyNow* lazy_now); 215 base::Optional<base::TimeDelta> ComputeDelayTillNextTask(LazyNow* lazy_now);
216 216
217 void MaybeRecordTaskDelayHistograms( 217 void MaybeRecordTaskDelayHistograms(
218 const internal::TaskQueueImpl::Task& pending_task, 218 const internal::TaskQueueImpl::Task& pending_task,
219 const internal::TaskQueueImpl* queue); 219 const internal::TaskQueueImpl* queue);
220 220
221 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 221 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
222 AsValueWithSelectorResult(bool should_run, 222 AsValueWithSelectorResult(bool should_run,
223 internal::WorkQueue* selected_work_queue) const; 223 internal::WorkQueue* selected_work_queue) const;
224 224
225 // Adds |queue| to |any_thread().has_incoming_immediate_work_| and if
226 // |queue_is_blocked| is false it makes sure a DoWork is posted.
227 // Can be called from any thread.
228 void OnQueueHasIncomingImmediateWork(internal::TaskQueueImpl* queue,
229 bool queue_is_blocked);
230
231 // Calls |ReloadImmediateWorkQueueIfEmpty| on all queues in
232 // |queues_to_reload|.
233 void ReloadEmptyWorkQueues(const std::unordered_set<internal::TaskQueueImpl*>&
234 queues_to_reload) const;
235
225 std::set<TimeDomain*> time_domains_; 236 std::set<TimeDomain*> time_domains_;
226 std::unique_ptr<RealTimeDomain> real_time_domain_; 237 std::unique_ptr<RealTimeDomain> real_time_domain_;
227 238
228 std::set<scoped_refptr<internal::TaskQueueImpl>> queues_; 239 std::set<scoped_refptr<internal::TaskQueueImpl>> queues_;
229 240
230 // We have to be careful when deleting a queue because some of the code uses 241 // We have to be careful when deleting a queue because some of the code uses
231 // raw pointers and doesn't expect the rug to be pulled out from underneath. 242 // raw pointers and doesn't expect the rug to be pulled out from underneath.
232 std::set<scoped_refptr<internal::TaskQueueImpl>> queues_to_delete_; 243 std::set<scoped_refptr<internal::TaskQueueImpl>> queues_to_delete_;
233 244
234 internal::EnqueueOrderGenerator enqueue_order_generator_; 245 internal::EnqueueOrderGenerator enqueue_order_generator_;
235 base::debug::TaskAnnotator task_annotator_; 246 base::debug::TaskAnnotator task_annotator_;
236 247
237 base::ThreadChecker main_thread_checker_; 248 base::ThreadChecker main_thread_checker_;
238 scoped_refptr<TaskQueueManagerDelegate> delegate_; 249 scoped_refptr<TaskQueueManagerDelegate> delegate_;
239 internal::TaskQueueSelector selector_; 250 internal::TaskQueueSelector selector_;
240 251
241 base::Closure from_main_thread_immediate_do_work_closure_; 252 base::Closure from_main_thread_immediate_do_work_closure_;
242 base::Closure from_other_thread_immediate_do_work_closure_; 253 base::Closure from_other_thread_immediate_do_work_closure_;
243 254
244 bool task_was_run_on_quiescence_monitored_queue_; 255 bool task_was_run_on_quiescence_monitored_queue_;
245 256
246 // To reduce locking overhead we track pending calls to DoWork separately for 257 // To reduce locking overhead we track pending calls to DoWork separately for
247 // the main thread and other threads. 258 // the main thread and other threads.
248 std::set<base::TimeTicks> main_thread_pending_wakeups_; 259 std::set<base::TimeTicks> main_thread_pending_wakeups_;
249 260
250 struct AnyThread { 261 struct AnyThread {
251 AnyThread(); 262 AnyThread();
252 263
264 // Set of task queues with newly available work on the incoming queue.
265 std::unordered_set<internal::TaskQueueImpl*> has_incoming_immediate_work;
266
253 bool other_thread_pending_wakeup; 267 bool other_thread_pending_wakeup;
254 }; 268 };
255 269
256 // TODO(alexclarke): Add a MainThreadOnly struct too. 270 // TODO(alexclarke): Add a MainThreadOnly struct too.
257 271
258 mutable base::Lock any_thread_lock_; 272 mutable base::Lock any_thread_lock_;
259 AnyThread any_thread_; 273 AnyThread any_thread_;
260 274
261 struct AnyThread& any_thread() { 275 struct AnyThread& any_thread() {
262 any_thread_lock_.AssertAcquired(); 276 any_thread_lock_.AssertAcquired();
(...skipping 23 matching lines...) Expand all
286 scoped_refptr<DeletionSentinel> deletion_sentinel_; 300 scoped_refptr<DeletionSentinel> deletion_sentinel_;
287 base::WeakPtrFactory<TaskQueueManager> weak_factory_; 301 base::WeakPtrFactory<TaskQueueManager> weak_factory_;
288 302
289 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager); 303 DISALLOW_COPY_AND_ASSIGN(TaskQueueManager);
290 }; 304 };
291 305
292 } // namespace scheduler 306 } // namespace scheduler
293 } // namespace blink 307 } // namespace blink
294 308
295 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_ H_ 309 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_MANAGER_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698