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

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

Issue 2579773002: Use WTF::Deque instead of std::queue in the blink scheduler (Closed)
Patch Set: Apply the fix Sami suggested Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/scheduler/base/work_queue.cc
diff --git a/third_party/WebKit/Source/platform/scheduler/base/work_queue.cc b/third_party/WebKit/Source/platform/scheduler/base/work_queue.cc
index fe168586f28104b75b14dee6a1869efce6bb80a2..0b7d0cd9b753d9850c3bf77138b99b39d16e49ed 100644
--- a/third_party/WebKit/Source/platform/scheduler/base/work_queue.cc
+++ b/third_party/WebKit/Source/platform/scheduler/base/work_queue.cc
@@ -18,17 +18,9 @@ WorkQueue::WorkQueue(TaskQueueImpl* task_queue, const char* name)
fence_(0) {}
void WorkQueue::AsValueInto(base::trace_event::TracedValue* state) const {
- // Remove const to search |work_queue_| in the destructive manner. Restore the
- // content from |visited| later.
- std::queue<TaskQueueImpl::Task>* mutable_queue =
- const_cast<std::queue<TaskQueueImpl::Task>*>(&work_queue_);
- std::queue<TaskQueueImpl::Task> visited;
- while (!mutable_queue->empty()) {
- TaskQueueImpl::TaskAsValueInto(mutable_queue->front(), state);
- visited.push(std::move(mutable_queue->front()));
- mutable_queue->pop();
+ for (const TaskQueueImpl::Task& task : work_queue_) {
+ TaskQueueImpl::TaskAsValueInto(task, state);
}
- *mutable_queue = std::move(visited);
}
WorkQueue::~WorkQueue() {
@@ -77,7 +69,7 @@ void WorkQueue::Push(TaskQueueImpl::Task task) {
#endif
// Amoritized O(1).
- work_queue_.push(std::move(task));
+ work_queue_.push_back(std::move(task));
if (!was_empty)
return;
@@ -90,12 +82,12 @@ void WorkQueue::Push(TaskQueueImpl::Task task) {
void WorkQueue::PopTaskForTest() {
if (work_queue_.empty())
return;
- work_queue_.pop();
+ work_queue_.pop_front();
}
-void WorkQueue::SwapLocked(std::queue<TaskQueueImpl::Task>& incoming_queue) {
+void WorkQueue::SwapLocked(WTF::Deque<TaskQueueImpl::Task>& incoming_queue) {
DCHECK(work_queue_.empty());
- std::swap(work_queue_, incoming_queue);
+ work_queue_.swap(incoming_queue);
if (work_queue_.empty())
return;
// If we hit the fence, pretend to WorkQueueSets that we're empty.
@@ -110,12 +102,10 @@ TaskQueueImpl::Task WorkQueue::TakeTaskFromWorkQueue() {
// Skip over canceled tasks, except for the last one since we always return
// something.
while (work_queue_.size() > 1u && work_queue_.front().task.IsCancelled()) {
- work_queue_.pop();
+ work_queue_.pop_front();
}
- TaskQueueImpl::Task pending_task =
- std::move(const_cast<TaskQueueImpl::Task&>(work_queue_.front()));
- work_queue_.pop();
+ TaskQueueImpl::Task pending_task = work_queue_.takeFirst();
work_queue_sets_->OnPopQueue(this);
task_queue_->TraceQueueSize(false);
return pending_task;

Powered by Google App Engine
This is Rietveld 408576698