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

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

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

Powered by Google App Engine
This is Rietveld 408576698