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

Side by Side Diff: base/message_loop/incoming_task_queue.cc

Issue 1886453003: Make PendingTask move-only and pass it by value on retaining params (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | base/message_loop/message_loop.h » ('j') | base/threading/worker_pool_posix.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/message_loop/incoming_task_queue.h" 5 #include "base/message_loop/incoming_task_queue.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 // Initialize the sequence number. The sequence number is used for delayed 149 // Initialize the sequence number. The sequence number is used for delayed
150 // tasks (to facilitate FIFO sorting when two tasks have the same 150 // tasks (to facilitate FIFO sorting when two tasks have the same
151 // delayed_run_time value) and for identifying the task in about:tracing. 151 // delayed_run_time value) and for identifying the task in about:tracing.
152 pending_task->sequence_num = next_sequence_num_++; 152 pending_task->sequence_num = next_sequence_num_++;
153 153
154 message_loop_->task_annotator()->DidQueueTask("MessageLoop::PostTask", 154 message_loop_->task_annotator()->DidQueueTask("MessageLoop::PostTask",
155 *pending_task); 155 *pending_task);
156 156
157 bool was_empty = incoming_queue_.empty(); 157 bool was_empty = incoming_queue_.empty();
158 incoming_queue_.push(*pending_task); 158 incoming_queue_.push(std::move(*pending_task));
159 pending_task->task.Reset(); 159 DCHECK(pending_task->task.is_null());
Sami 2016/04/13 11:33:00 Is this a valid assumption? I thought we should tr
tzik 2016/04/13 14:35:37 Done.
Sami 2016/04/13 15:17:32 I'm not sure we need to even do this. We've moved
tzik 2016/04/14 19:44:30 Right, it's redundant since we know the move const
160 160
161 if (is_ready_for_scheduling_ && 161 if (is_ready_for_scheduling_ &&
162 (always_schedule_work_ || (!message_loop_scheduled_ && was_empty))) { 162 (always_schedule_work_ || (!message_loop_scheduled_ && was_empty))) {
163 ScheduleWork(); 163 ScheduleWork();
164 } 164 }
165 165
166 return true; 166 return true;
167 } 167 }
168 168
169 void IncomingTaskQueue::ScheduleWork() { 169 void IncomingTaskQueue::ScheduleWork() {
170 DCHECK(is_ready_for_scheduling_); 170 DCHECK(is_ready_for_scheduling_);
171 // Wake up the message loop. 171 // Wake up the message loop.
172 message_loop_->ScheduleWork(); 172 message_loop_->ScheduleWork();
173 // After we've scheduled the message loop, we do not need to do so again 173 // After we've scheduled the message loop, we do not need to do so again
174 // until we know it has processed all of the work in our queue and is 174 // until we know it has processed all of the work in our queue and is
175 // waiting for more work again. The message loop will always attempt to 175 // waiting for more work again. The message loop will always attempt to
176 // reload from the incoming queue before waiting again so we clear this flag 176 // reload from the incoming queue before waiting again so we clear this flag
177 // in ReloadWorkQueue(). 177 // in ReloadWorkQueue().
178 message_loop_scheduled_ = true; 178 message_loop_scheduled_ = true;
179 } 179 }
180 180
181 } // namespace internal 181 } // namespace internal
182 } // namespace base 182 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/message_loop/message_loop.h » ('j') | base/threading/worker_pool_posix.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698