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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/base/work_queue.cc

Issue 2590593002: Revert of [Reland] Scheduler refactoring to virtually eliminate redundant DoWorks (Closed)
Patch Set: Created 3 years, 12 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 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 #include "platform/scheduler/base/work_queue.h" 5 #include "platform/scheduler/base/work_queue.h"
6 6
7 #include "platform/scheduler/base/work_queue_sets.h" 7 #include "platform/scheduler/base/work_queue_sets.h"
8 8
9 namespace blink { 9 namespace blink {
10 namespace scheduler { 10 namespace scheduler {
11 namespace internal { 11 namespace internal {
12 12
13 WorkQueue::WorkQueue(TaskQueueImpl* task_queue, 13 WorkQueue::WorkQueue(TaskQueueImpl* task_queue, const char* name)
14 const char* name,
15 QueueType queue_type)
16 : work_queue_sets_(nullptr), 14 : work_queue_sets_(nullptr),
17 task_queue_(task_queue), 15 task_queue_(task_queue),
18 work_queue_set_index_(0), 16 work_queue_set_index_(0),
19 name_(name), 17 name_(name),
20 fence_(0), 18 fence_(0) {}
21 queue_type_(queue_type) {}
22 19
23 void WorkQueue::AsValueInto(base::trace_event::TracedValue* state) const { 20 void WorkQueue::AsValueInto(base::trace_event::TracedValue* state) const {
24 // Remove const to search |work_queue_| in the destructive manner. Restore the 21 // Remove const to search |work_queue_| in the destructive manner. Restore the
25 // content from |visited| later. 22 // content from |visited| later.
26 std::queue<TaskQueueImpl::Task>* mutable_queue = 23 std::queue<TaskQueueImpl::Task>* mutable_queue =
27 const_cast<std::queue<TaskQueueImpl::Task>*>(&work_queue_); 24 const_cast<std::queue<TaskQueueImpl::Task>*>(&work_queue_);
28 std::queue<TaskQueueImpl::Task> visited; 25 std::queue<TaskQueueImpl::Task> visited;
29 while (!mutable_queue->empty()) { 26 while (!mutable_queue->empty()) {
30 TaskQueueImpl::TaskAsValueInto(mutable_queue->front(), state); 27 TaskQueueImpl::TaskAsValueInto(mutable_queue->front(), state);
31 visited.push(std::move(mutable_queue->front())); 28 visited.push(std::move(mutable_queue->front()));
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 109
113 // Skip over canceled tasks, except for the last one since we always return 110 // Skip over canceled tasks, except for the last one since we always return
114 // something. 111 // something.
115 while (work_queue_.size() > 1u && work_queue_.front().task.IsCancelled()) { 112 while (work_queue_.size() > 1u && work_queue_.front().task.IsCancelled()) {
116 work_queue_.pop(); 113 work_queue_.pop();
117 } 114 }
118 115
119 TaskQueueImpl::Task pending_task = 116 TaskQueueImpl::Task pending_task =
120 std::move(const_cast<TaskQueueImpl::Task&>(work_queue_.front())); 117 std::move(const_cast<TaskQueueImpl::Task&>(work_queue_.front()));
121 work_queue_.pop(); 118 work_queue_.pop();
122 // NB immediate tasks have a different pipeline to delayed ones.
123 if (queue_type_ == QueueType::IMMEDIATE && work_queue_.empty())
124 task_queue_->OnImmediateWorkQueueHasBecomeEmpty(&work_queue_);
125 // OnPopQueue checks BlockedByFence() so we don't need to here.
126 work_queue_sets_->OnPopQueue(this); 119 work_queue_sets_->OnPopQueue(this);
127 task_queue_->TraceQueueSize(false); 120 task_queue_->TraceQueueSize(false);
128 return pending_task; 121 return pending_task;
129 } 122 }
130 123
131 void WorkQueue::AssignToWorkQueueSets(WorkQueueSets* work_queue_sets) { 124 void WorkQueue::AssignToWorkQueueSets(WorkQueueSets* work_queue_sets) {
132 work_queue_sets_ = work_queue_sets; 125 work_queue_sets_ = work_queue_sets;
133 } 126 }
134 127
135 void WorkQueue::AssignSetIndex(size_t work_queue_set_index) { 128 void WorkQueue::AssignSetIndex(size_t work_queue_set_index) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 bool have_other_task = 165 bool have_other_task =
173 other_queue->GetFrontTaskEnqueueOrder(&other_enqueue_order); 166 other_queue->GetFrontTaskEnqueueOrder(&other_enqueue_order);
174 DCHECK(have_task); 167 DCHECK(have_task);
175 DCHECK(have_other_task); 168 DCHECK(have_other_task);
176 return enqueue_order < other_enqueue_order; 169 return enqueue_order < other_enqueue_order;
177 } 170 }
178 171
179 } // namespace internal 172 } // namespace internal
180 } // namespace scheduler 173 } // namespace scheduler
181 } // namespace blink 174 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698