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

Unified Diff: base/task_scheduler/sequence_sort_key.h

Issue 1705253002: TaskScheduler [3/9] Task and Sequence (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@s_1_scheduler_lock
Patch Set: Created 4 years, 10 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
new file mode 100644
index 0000000000000000000000000000000000000000..3a02ab05ffec217d3c53f94120fa3a239d9817e6
--- /dev/null
+++ b/base/task_scheduler/sequence_sort_key.h
@@ -0,0 +1,46 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_TASK_SCHEDULER_SEQUENCE_SORT_KEY_H_
+#define BASE_TASK_SCHEDULER_SEQUENCE_SORT_KEY_H_
+
+#include "base/base_export.h"
+#include "base/gtest_prod_util.h"
+#include "base/task_scheduler/task_traits.h"
+#include "base/time/time.h"
+
+namespace base {
+namespace internal {
+
+// A SequenceSortKey determines the position of a Sequence in a PriorityQueue.
+// Contrary to a Sequence, which can be modified when it is inside a
+// PriorityQueue, a SequenceSortKey is immutable.
+class BASE_EXPORT SequenceSortKey {
+ public:
+ SequenceSortKey();
+ SequenceSortKey(TaskPriority priority, TimeTicks next_task_post_time);
gab 2016/02/18 03:00:46 Add comments on constructors to highlight differen
fdoray 2016/02/18 14:56:12 Default constructor is not needed.
+
+ // Returns true if the the sequence associated with this sort key must run
+ // after the sequence associated with |other|.
fdoray 2016/02/18 01:46:11 Or, more simply: Indicates whether the priority o
gab 2016/02/18 03:00:46 Or more simply: no comment as this is implicit fro
fdoray 2016/02/18 14:56:12 Done.
+ bool operator<(const SequenceSortKey& other) const;
+
+ // Used for testing.
gab 2016/02/18 03:00:46 Wouldn't bother with this comment.
fdoray 2016/02/18 14:56:12 Done.
+ bool operator==(const SequenceSortKey& other) const;
+
+ TaskPriority priority() const { return priority_; }
+
+ private:
+ FRIEND_TEST_ALL_PREFIXES(TaskSchedulerSequenceTest, GetSequenceSortKey);
gab 2016/02/18 03:00:46 Let's make this a struct with public members, does
fdoray 2016/02/18 14:56:12 As explained below, the members can't be const. I
+
+ // Highest task priority in the sequence at the time this sort key is created.
fdoray 2016/02/18 01:46:11 *was created?
gab 2016/02/18 03:00:46 Yes.
fdoray 2016/02/18 14:56:13 Done.
+ TaskPriority priority_;
gab 2016/02/18 03:00:46 const
fdoray 2016/02/18 14:56:12 Sadly, std::priority_queue needs operator=, which
gab 2016/02/18 20:22:34 Ugh :-(... really?! It does in place replacements
gab 2016/02/18 21:21:16 Resurfacing this.
fdoray 2016/02/18 22:19:53 Done.
+
+ // Post time of the next task to run in the sequence.
fdoray 2016/02/18 01:46:11 ... at the time this sort key was created.
fdoray 2016/02/18 14:56:12 Done.
+ TimeTicks next_task_post_time_;
gab 2016/02/18 03:00:46 const
fdoray 2016/02/18 14:56:12 Same comment as above.
+};
+
+} // namespace internal
+} // namespace base
+
+#endif // BASE_TASK_SCHEDULER_SEQUENCE_SORT_KEY_H_

Powered by Google App Engine
This is Rietveld 408576698