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

Unified Diff: base/task_scheduler/sequence_sort_key.h

Issue 1903133003: TaskScheduler: Avoid Sequence refcount bump in GetWork() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review:robliao/fdoray#14-15 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 side-by-side diff with in-line comments
Download patch
Index: base/task_scheduler/sequence_sort_key.h
diff --git a/base/task_scheduler/sequence_sort_key.h b/base/task_scheduler/sequence_sort_key.h
index f2dd561c0fa207d36c97a75d73c0f2694019ff30..4f23767c99e05d4270a2a5841963b32a898066c9 100644
--- a/base/task_scheduler/sequence_sort_key.h
+++ b/base/task_scheduler/sequence_sort_key.h
@@ -13,19 +13,32 @@ namespace base {
namespace internal {
// An immutable representation of the priority of a Sequence.
danakj 2016/04/27 20:50:59 maybe you should say "immutable but copyable" or "
gab 2016/04/28 13:47:15 Done.
-struct BASE_EXPORT SequenceSortKey final {
+class BASE_EXPORT SequenceSortKey final {
+ public:
SequenceSortKey(TaskPriority priority, TimeTicks next_task_sequenced_time);
bool operator<(const SequenceSortKey& other) const;
bool operator>(const SequenceSortKey& other) const { return other < *this; }
+ bool operator==(const SequenceSortKey& other) const {
+ return priority_ == other.priority_ &&
+ next_task_sequenced_time_ == other.next_task_sequenced_time_;
+ }
+ bool operator!=(const SequenceSortKey& other) const {
+ return !(other == *this);
+ };
+
+ private:
+ // The private section allows this class to keep its immutable property while
+ // being copy-assignable (i.e. instead of making its members const).
+
// Highest task priority in the sequence at the time this sort key was
// created.
- const TaskPriority priority;
+ TaskPriority priority_;
// Sequenced time of the next task to run in the sequence at the time this
// sort key was created.
- const TimeTicks next_task_sequenced_time;
+ TimeTicks next_task_sequenced_time_;
};
} // namespace internal

Powered by Google App Engine
This is Rietveld 408576698