Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/task_scheduler/sequence_sort_key.h" | |
| 6 | |
| 7 namespace base { | |
| 8 namespace internal { | |
| 9 | |
| 10 SequenceSortKey::SequenceSortKey(TaskPriority priority, | |
| 11 TimeTicks next_task_sequenced_time) | |
| 12 : priority_(priority), | |
| 13 next_task_sequenced_time_(next_task_sequenced_time) {} | |
| 14 | |
| 15 bool SequenceSortKey::operator<(const SequenceSortKey& other) const { | |
| 16 // Sort by highest priority first, earliest post time second. | |
|
gab
2016/02/18 20:22:34
Actually (sorry I know I wrote this...), how about
fdoray
2016/02/18 20:52:04
Done.
| |
| 17 const int priority_diff = | |
| 18 static_cast<TaskPriorityUnderlyingType>(other.priority_) - | |
| 19 static_cast<TaskPriorityUnderlyingType>(priority_); | |
| 20 return priority_diff != 0 | |
| 21 ? priority_diff > 0 | |
| 22 : next_task_sequenced_time_ > other.next_task_sequenced_time_; | |
| 23 } | |
| 24 | |
| 25 bool SequenceSortKey::operator==(const SequenceSortKey& other) const { | |
| 26 return priority_ == other.priority_ && | |
| 27 next_task_sequenced_time_ == other.next_task_sequenced_time_; | |
| 28 } | |
| 29 | |
| 30 } // namespace internal | |
| 31 } // namespace base | |
| OLD | NEW |