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

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

Issue 2718293003: scheduler: Ensure consistent delayed task ordering between task queues (Closed)
Patch Set: Review comments Created 3 years, 9 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/scheduler/base/task_queue_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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_IMPL_H_ 5 #ifndef THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_
6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ 6 #define THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 bool enqueue_order_set_; 104 bool enqueue_order_set_;
105 #endif 105 #endif
106 // Similar to sequence number, but ultimately the |enqueue_order_| is what 106 // Similar to sequence number, but ultimately the |enqueue_order_| is what
107 // the scheduler uses for task ordering. For immediate tasks |enqueue_order| 107 // the scheduler uses for task ordering. For immediate tasks |enqueue_order|
108 // is set when posted, but for delayed tasks it's not defined until they are 108 // is set when posted, but for delayed tasks it's not defined until they are
109 // enqueued on the |delayed_work_queue_|. This is because otherwise delayed 109 // enqueued on the |delayed_work_queue_|. This is because otherwise delayed
110 // tasks could run before an immediate task posted after the delayed task. 110 // tasks could run before an immediate task posted after the delayed task.
111 EnqueueOrder enqueue_order_; 111 EnqueueOrder enqueue_order_;
112 }; 112 };
113 113
114 // Represents a time at which a task wants to run. Tasks scheduled for the
115 // same point in time will be ordered by their sequence numbers.
116 struct DelayedWakeUp {
117 base::TimeTicks time;
118 int sequence_num;
119
120 bool operator<=(const DelayedWakeUp& other) const {
121 if (time == other.time) {
122 DCHECK_NE(sequence_num, other.sequence_num);
123 return (sequence_num - other.sequence_num) < 0;
124 }
125 return time < other.time;
126 }
127 };
128
114 // TaskQueue implementation. 129 // TaskQueue implementation.
115 void UnregisterTaskQueue() override; 130 void UnregisterTaskQueue() override;
116 bool RunsTasksOnCurrentThread() const override; 131 bool RunsTasksOnCurrentThread() const override;
117 bool PostDelayedTask(const tracked_objects::Location& from_here, 132 bool PostDelayedTask(const tracked_objects::Location& from_here,
118 const base::Closure& task, 133 const base::Closure& task,
119 base::TimeDelta delay) override; 134 base::TimeDelta delay) override;
120 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here, 135 bool PostNonNestableDelayedTask(const tracked_objects::Location& from_here,
121 const base::Closure& task, 136 const base::Closure& task,
122 base::TimeDelta delay) override; 137 base::TimeDelta delay) override;
123 std::unique_ptr<QueueEnabledVoter> CreateQueueEnabledVoter() override; 138 std::unique_ptr<QueueEnabledVoter> CreateQueueEnabledVoter() override;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 185
171 const WorkQueue* immediate_work_queue() const { 186 const WorkQueue* immediate_work_queue() const {
172 return main_thread_only().immediate_work_queue.get(); 187 return main_thread_only().immediate_work_queue.get();
173 } 188 }
174 189
175 bool should_report_when_execution_blocked() const { 190 bool should_report_when_execution_blocked() const {
176 return should_report_when_execution_blocked_; 191 return should_report_when_execution_blocked_;
177 } 192 }
178 193
179 // Enqueues any delayed tasks which should be run now on the 194 // Enqueues any delayed tasks which should be run now on the
180 // |delayed_work_queue|. Returns the deadline if a subsequent wakeup is 195 // |delayed_work_queue|. Returns the subsequent wakeup that is required, if
181 // required. Must be called from the main thread. 196 // any. Must be called from the main thread.
182 base::Optional<base::TimeTicks> WakeUpForDelayedWork(LazyNow* lazy_now); 197 base::Optional<DelayedWakeUp> WakeUpForDelayedWork(LazyNow* lazy_now);
183 198
184 base::TimeTicks scheduled_time_domain_wakeup() const { 199 base::TimeTicks scheduled_time_domain_wakeup() const {
185 return main_thread_only().scheduled_time_domain_wakeup; 200 return main_thread_only().scheduled_time_domain_wakeup;
186 } 201 }
187 202
188 void set_scheduled_time_domain_wakeup( 203 void set_scheduled_time_domain_wakeup(
189 base::TimeTicks scheduled_time_domain_wakeup) { 204 base::TimeTicks scheduled_time_domain_wakeup) {
190 main_thread_only().scheduled_time_domain_wakeup = 205 main_thread_only().scheduled_time_domain_wakeup =
191 scheduled_time_domain_wakeup; 206 scheduled_time_domain_wakeup;
192 } 207 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 const bool should_report_when_execution_blocked_; 364 const bool should_report_when_execution_blocked_;
350 365
351 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl); 366 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl);
352 }; 367 };
353 368
354 } // namespace internal 369 } // namespace internal
355 } // namespace scheduler 370 } // namespace scheduler
356 } // namespace blink 371 } // namespace blink
357 372
358 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ 373 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698