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

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

Issue 2785943004: DCHECK tasks posted by TaskRunner::PostTask (Closed)
Patch Set: fix Created 3 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
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/sequence.h" 5 #include "base/task_scheduler/sequence.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 11
12 namespace base { 12 namespace base {
13 namespace internal { 13 namespace internal {
14 14
15 Sequence::Sequence() = default; 15 Sequence::Sequence() = default;
16 16
17 bool Sequence::PushTask(std::unique_ptr<Task> task) { 17 bool Sequence::PushTask(std::unique_ptr<Task> task) {
18 DCHECK(task);
19 DCHECK(task->task);
18 DCHECK(task->sequenced_time.is_null()); 20 DCHECK(task->sequenced_time.is_null());
19 task->sequenced_time = base::TimeTicks::Now(); 21 task->sequenced_time = base::TimeTicks::Now();
20 22
21 AutoSchedulerLock auto_lock(lock_); 23 AutoSchedulerLock auto_lock(lock_);
22 ++num_tasks_per_priority_[static_cast<int>(task->traits.priority())]; 24 ++num_tasks_per_priority_[static_cast<int>(task->traits.priority())];
23 queue_.push(std::move(task)); 25 queue_.push(std::move(task));
24 26
25 // Return true if the sequence was empty before the push. 27 // Return true if the sequence was empty before the push.
26 return queue_.size() == 1; 28 return queue_.size() == 1;
27 } 29 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 next_task_sequenced_time = queue_.front()->sequenced_time; 78 next_task_sequenced_time = queue_.front()->sequenced_time;
77 } 79 }
78 80
79 return SequenceSortKey(priority, next_task_sequenced_time); 81 return SequenceSortKey(priority, next_task_sequenced_time);
80 } 82 }
81 83
82 Sequence::~Sequence() = default; 84 Sequence::~Sequence() = default;
83 85
84 } // namespace internal 86 } // namespace internal
85 } // namespace base 87 } // namespace base
OLDNEW
« no previous file with comments | « base/task_scheduler/scheduler_worker_pool_impl.cc ('k') | base/task_scheduler/sequence_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698