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

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

Issue 2533603002: [scheduler] Add options to TaskQueue::InsertFence (Closed)
Patch Set: More nits 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 {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 void WorkQueue::AssignToWorkQueueSets(WorkQueueSets* work_queue_sets) { 124 void WorkQueue::AssignToWorkQueueSets(WorkQueueSets* work_queue_sets) {
125 work_queue_sets_ = work_queue_sets; 125 work_queue_sets_ = work_queue_sets;
126 } 126 }
127 127
128 void WorkQueue::AssignSetIndex(size_t work_queue_set_index) { 128 void WorkQueue::AssignSetIndex(size_t work_queue_set_index) {
129 work_queue_set_index_ = work_queue_set_index; 129 work_queue_set_index_ = work_queue_set_index;
130 } 130 }
131 131
132 bool WorkQueue::InsertFence(EnqueueOrder fence) { 132 bool WorkQueue::InsertFence(EnqueueOrder fence) {
133 DCHECK_NE(fence, 0u); 133 DCHECK_NE(fence, 0u);
134 DCHECK_GE(fence, fence_); 134 DCHECK(fence >= fence_ || fence == 1u);
135 bool was_blocked_by_fence = BlockedByFence(); 135 bool was_blocked_by_fence = BlockedByFence();
136 fence_ = fence; 136 fence_ = fence;
137 // Moving the fence forward may unblock some tasks. 137 // Moving the fence forward may unblock some tasks.
138 if (work_queue_sets_ && !work_queue_.empty() && was_blocked_by_fence && 138 if (work_queue_sets_ && !work_queue_.empty() && was_blocked_by_fence &&
139 !BlockedByFence()) { 139 !BlockedByFence()) {
140 work_queue_sets_->OnPushQueue(this); 140 work_queue_sets_->OnPushQueue(this);
141 return true; 141 return true;
142 } 142 }
143 // Fence insertion may have blocked all tasks in this work queue.
144 if (BlockedByFence())
145 work_queue_sets_->OnQueueBlocked(this);
143 return false; 146 return false;
144 } 147 }
145 148
146 bool WorkQueue::RemoveFence() { 149 bool WorkQueue::RemoveFence() {
147 bool was_blocked_by_fence = BlockedByFence(); 150 bool was_blocked_by_fence = BlockedByFence();
148 fence_ = 0; 151 fence_ = 0;
149 if (work_queue_sets_ && !work_queue_.empty() && was_blocked_by_fence) { 152 if (work_queue_sets_ && !work_queue_.empty() && was_blocked_by_fence) {
150 work_queue_sets_->OnPushQueue(this); 153 work_queue_sets_->OnPushQueue(this);
151 return true; 154 return true;
152 } 155 }
153 return false; 156 return false;
154 } 157 }
155 158
156 bool WorkQueue::ShouldRunBefore(const WorkQueue* other_queue) const { 159 bool WorkQueue::ShouldRunBefore(const WorkQueue* other_queue) const {
157 DCHECK(!work_queue_.empty()); 160 DCHECK(!work_queue_.empty());
158 DCHECK(!other_queue->work_queue_.empty()); 161 DCHECK(!other_queue->work_queue_.empty());
159 EnqueueOrder enqueue_order = 0; 162 EnqueueOrder enqueue_order = 0;
160 EnqueueOrder other_enqueue_order = 0; 163 EnqueueOrder other_enqueue_order = 0;
161 bool have_task = GetFrontTaskEnqueueOrder(&enqueue_order); 164 bool have_task = GetFrontTaskEnqueueOrder(&enqueue_order);
162 bool have_other_task = 165 bool have_other_task =
163 other_queue->GetFrontTaskEnqueueOrder(&other_enqueue_order); 166 other_queue->GetFrontTaskEnqueueOrder(&other_enqueue_order);
164 DCHECK(have_task); 167 DCHECK(have_task);
165 DCHECK(have_other_task); 168 DCHECK(have_other_task);
166 return enqueue_order < other_enqueue_order; 169 return enqueue_order < other_enqueue_order;
167 } 170 }
168 171
169 } // namespace internal 172 } // namespace internal
170 } // namespace scheduler 173 } // namespace scheduler
171 } // namespace blink 174 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698