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

Side by Side Diff: base/task_scheduler/task_tracker.cc

Issue 2399213005: TaskScheduler: Change Sequence::PeekTask to Sequence::TakeTask. (Closed)
Patch Set: CR robliao #5 Created 4 years, 2 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 | « base/task_scheduler/task_tracker.h ('k') | base/task_scheduler/task_tracker_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/task_scheduler/task_tracker.h" 5 #include "base/task_scheduler/task_tracker.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/debug/task_annotator.h" 10 #include "base/debug/task_annotator.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 if (task->delayed_run_time.is_null()) 199 if (task->delayed_run_time.is_null())
200 subtle::NoBarrier_AtomicIncrement(&num_pending_undelayed_tasks_, 1); 200 subtle::NoBarrier_AtomicIncrement(&num_pending_undelayed_tasks_, 1);
201 201
202 debug::TaskAnnotator task_annotator; 202 debug::TaskAnnotator task_annotator;
203 task_annotator.DidQueueTask(kQueueFunctionName, *task); 203 task_annotator.DidQueueTask(kQueueFunctionName, *task);
204 204
205 return true; 205 return true;
206 } 206 }
207 207
208 bool TaskTracker::RunTask(const Task* task, 208 bool TaskTracker::RunTask(std::unique_ptr<Task> task,
209 const SequenceToken& sequence_token) { 209 const SequenceToken& sequence_token) {
210 DCHECK(task); 210 DCHECK(task);
211 DCHECK(sequence_token.IsValid()); 211 DCHECK(sequence_token.IsValid());
212 212
213 const TaskShutdownBehavior shutdown_behavior = 213 const TaskShutdownBehavior shutdown_behavior =
214 task->traits.shutdown_behavior(); 214 task->traits.shutdown_behavior();
215 const bool can_run_task = BeforeRunTask(shutdown_behavior); 215 const bool can_run_task = BeforeRunTask(shutdown_behavior);
216 216
217 if (can_run_task) { 217 if (can_run_task) {
218 // All tasks run through here and the scheduler itself doesn't use 218 // All tasks run through here and the scheduler itself doesn't use
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 subtle::NoBarrier_AtomicIncrement(&num_pending_undelayed_tasks_, -1); 435 subtle::NoBarrier_AtomicIncrement(&num_pending_undelayed_tasks_, -1);
436 DCHECK_GE(new_num_pending_undelayed_tasks, 0); 436 DCHECK_GE(new_num_pending_undelayed_tasks, 0);
437 if (new_num_pending_undelayed_tasks == 0) { 437 if (new_num_pending_undelayed_tasks == 0) {
438 AutoSchedulerLock auto_lock(flush_lock_); 438 AutoSchedulerLock auto_lock(flush_lock_);
439 flush_cv_->Signal(); 439 flush_cv_->Signal();
440 } 440 }
441 } 441 }
442 442
443 } // namespace internal 443 } // namespace internal
444 } // namespace base 444 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/task_tracker.h ('k') | base/task_scheduler/task_tracker_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698