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

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

Issue 2546423002: [Try # 3] Scheduler refactoring to virtually eliminate redundant DoWorks (Closed)
Patch Set: Fix lock order inversion Created 4 years 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 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 base::MessageLoop::TaskObserver* task_observer) override; 132 base::MessageLoop::TaskObserver* task_observer) override;
133 void SetTimeDomain(TimeDomain* time_domain) override; 133 void SetTimeDomain(TimeDomain* time_domain) override;
134 TimeDomain* GetTimeDomain() const override; 134 TimeDomain* GetTimeDomain() const override;
135 void SetBlameContext(base::trace_event::BlameContext* blame_context) override; 135 void SetBlameContext(base::trace_event::BlameContext* blame_context) override;
136 void InsertFence(InsertFencePosition position) override; 136 void InsertFence(InsertFencePosition position) override;
137 void RemoveFence() override; 137 void RemoveFence() override;
138 bool BlockedByFence() const override; 138 bool BlockedByFence() const override;
139 const char* GetName() const override; 139 const char* GetName() const override;
140 QueueType GetQueueType() const override; 140 QueueType GetQueueType() const override;
141 141
142 // If this returns false then future updates for this queue are not needed 142 // As BlockedByFence but only safe to be called while |any_thread_| is locked.
143 // unless requested. 143 // Must only be called from the thread this task queue was created on.
144 bool MaybeUpdateImmediateWorkQueues(); 144 bool BlockedByFenceLocked() const;
145
146 // Must only be called from the thread this task queue was created on.
147 void OnImmediateWorkQueueHasBecomeEmpty(
148 std::queue<TaskQueueImpl::Task>* work_queue);
149
150 // Must only be called from the thread this task queue was created on.
151 void ReloadImmediateWorkQueueIfEmpty();
145 152
146 void AsValueInto(base::trace_event::TracedValue* state) const; 153 void AsValueInto(base::trace_event::TracedValue* state) const;
147 154
148 bool GetQuiescenceMonitored() const { return should_monitor_quiescence_; } 155 bool GetQuiescenceMonitored() const { return should_monitor_quiescence_; }
149 bool GetShouldNotifyObservers() const { return should_notify_observers_; } 156 bool GetShouldNotifyObservers() const { return should_notify_observers_; }
150 157
151 void NotifyWillProcessTask(const base::PendingTask& pending_task); 158 void NotifyWillProcessTask(const base::PendingTask& pending_task);
152 void NotifyDidProcessTask(const base::PendingTask& pending_task); 159 void NotifyDidProcessTask(const base::PendingTask& pending_task);
153 160
154 WorkQueue* delayed_work_queue() { 161 WorkQueue* delayed_work_queue() {
(...skipping 10 matching lines...) Expand all
165 172
166 const WorkQueue* immediate_work_queue() const { 173 const WorkQueue* immediate_work_queue() const {
167 return main_thread_only().immediate_work_queue.get(); 174 return main_thread_only().immediate_work_queue.get();
168 } 175 }
169 176
170 bool should_report_when_execution_blocked() const { 177 bool should_report_when_execution_blocked() const {
171 return should_report_when_execution_blocked_; 178 return should_report_when_execution_blocked_;
172 } 179 }
173 180
174 // Enqueues any delayed tasks which should be run now on the 181 // Enqueues any delayed tasks which should be run now on the
175 // |delayed_work_queue|. It also schedules the next wake up with the 182 // |delayed_work_queue|. Returns the deadline if a subsequent wakeup is
176 // TimeDomain. Must be called from the main thread. 183 // required. Must be called from the main thread.
177 void WakeUpForDelayedWork(LazyNow* lazy_now); 184 base::Optional<base::TimeTicks> WakeUpForDelayedWork(LazyNow* lazy_now);
178 185
179 base::TimeTicks scheduled_time_domain_wakeup() const { 186 base::TimeTicks scheduled_time_domain_wakeup() const {
180 return main_thread_only().scheduled_time_domain_wakeup; 187 return main_thread_only().scheduled_time_domain_wakeup;
181 } 188 }
182 189
183 void set_scheduled_time_domain_wakeup( 190 void set_scheduled_time_domain_wakeup(
184 base::TimeTicks scheduled_time_domain_wakeup) { 191 base::TimeTicks scheduled_time_domain_wakeup) {
185 main_thread_only().scheduled_time_domain_wakeup = 192 main_thread_only().scheduled_time_domain_wakeup =
186 scheduled_time_domain_wakeup; 193 scheduled_time_domain_wakeup;
187 } 194 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 // Push the task onto the |immediate_incoming_queue| and for auto pumped 290 // Push the task onto the |immediate_incoming_queue| and for auto pumped
284 // queues it calls MaybePostDoWorkOnMainRunner if the Incoming queue was 291 // queues it calls MaybePostDoWorkOnMainRunner if the Incoming queue was
285 // empty. 292 // empty.
286 void PushOntoImmediateIncomingQueueLocked( 293 void PushOntoImmediateIncomingQueueLocked(
287 const tracked_objects::Location& posted_from, 294 const tracked_objects::Location& posted_from,
288 const base::Closure& task, 295 const base::Closure& task,
289 base::TimeTicks desired_run_time, 296 base::TimeTicks desired_run_time,
290 EnqueueOrder sequence_number, 297 EnqueueOrder sequence_number,
291 bool nestable); 298 bool nestable);
292 299
293 // As BlockedByFence but safe to be called while locked.
294 bool BlockedByFenceLocked() const;
295
296 void TraceQueueSize(bool is_locked) const; 300 void TraceQueueSize(bool is_locked) const;
297 static void QueueAsValueInto(const std::queue<Task>& queue, 301 static void QueueAsValueInto(const std::queue<Task>& queue,
298 base::trace_event::TracedValue* state); 302 base::trace_event::TracedValue* state);
299 static void QueueAsValueInto(const std::priority_queue<Task>& queue, 303 static void QueueAsValueInto(const std::priority_queue<Task>& queue,
300 base::trace_event::TracedValue* state); 304 base::trace_event::TracedValue* state);
301 static void TaskAsValueInto(const Task& task, 305 static void TaskAsValueInto(const Task& task,
302 base::trace_event::TracedValue* state); 306 base::trace_event::TracedValue* state);
303 307
304 void RemoveQueueEnabledVoter(const QueueEnabledVoterImpl* voter); 308 void RemoveQueueEnabledVoter(const QueueEnabledVoterImpl* voter);
305 void OnQueueEnabledVoteChanged(bool enabled); 309 void OnQueueEnabledVoteChanged(bool enabled);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 const bool should_report_when_execution_blocked_; 343 const bool should_report_when_execution_blocked_;
340 344
341 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl); 345 DISALLOW_COPY_AND_ASSIGN(TaskQueueImpl);
342 }; 346 };
343 347
344 } // namespace internal 348 } // namespace internal
345 } // namespace scheduler 349 } // namespace scheduler
346 } // namespace blink 350 } // namespace blink
347 351
348 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_ 352 #endif // THIRD_PARTY_WEBKIT_SOURCE_PLATFORM_SCHEDULER_BASE_TASK_QUEUE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698