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

Unified Diff: third_party/WebKit/Source/platform/scheduler/base/enqueue_order.h

Issue 2786083005: scheduler: Maintain a constant enqueue order for every task (Closed)
Patch Set: Update VirtualTimeTest 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/scheduler/base/enqueue_order.h
diff --git a/third_party/WebKit/Source/platform/scheduler/base/enqueue_order.h b/third_party/WebKit/Source/platform/scheduler/base/enqueue_order.h
index 04932d54376478f53556d100ef23692280bee6ff..9b7794a4fc9051e854a7697a24fddd83c9de1ddc 100644
--- a/third_party/WebKit/Source/platform/scheduler/base/enqueue_order.h
+++ b/third_party/WebKit/Source/platform/scheduler/base/enqueue_order.h
@@ -8,41 +8,49 @@
#include <stdint.h>
#include "base/synchronization/lock.h"
+#include "public/platform/WebCommon.h"
namespace blink {
namespace scheduler {
namespace internal {
-using EnqueueOrder = uint64_t;
+// The enqueue order is used to uniquely order tasks. The primary ordering key
+// is the desired run time of a task, followed by the sequence number. Note the
+// scheduler assumes sequence numbers will not overflow.
+struct BLINK_PLATFORM_EXPORT EnqueueOrder {
+ base::TimeTicks delayed_run_time;
+ uint64_t sequence_num;
alex clarke (OOO till 29th) 2017/04/13 07:46:00 I wonder if we should have using SequenceNum = ui
Sami 2017/04/18 10:47:49 Good idea, done.
-// TODO(scheduler-dev): Remove explicit casts when c++17 comes.
-enum class EnqueueOrderValues : EnqueueOrder {
- // Invalid EnqueueOrder.
+ bool is_null() const { return delayed_run_time.is_null() && !sequence_num; }
+
+ bool operator==(const EnqueueOrder& other) const;
+ bool operator<=(const EnqueueOrder& other) const;
+ bool operator<(const EnqueueOrder& other) const;
+};
+
+std::ostream& operator<<(std::ostream&, const EnqueueOrder&);
+
+enum class EnqueueOrderSequenceNumberValues {
+ // Invalid sequence number.
NONE = 0,
- // Earliest possible EnqueueOrder, to be used for fence blocking.
+ // Earliest possible sequence number, to be used for fence blocking.
BLOCKING_FENCE = 1,
FIRST = 2,
};
-// A 64bit integer used to provide ordering of tasks. NOTE The scheduler assumes
alex clarke (OOO till 29th) 2017/04/13 07:46:00 We should keep the comment about not overflowing.
Sami 2017/04/18 10:47:49 Yep, it's now further up the file where the enqueu
-// these values will not overflow.
class EnqueueOrderGenerator {
public:
EnqueueOrderGenerator();
~EnqueueOrderGenerator();
- // Returns a monotonically increasing integer, starting from one. Can be
+ // Returns a monotonically increasing enqueue order, starting from one. Can be
// called from any thread.
- EnqueueOrder GenerateNext();
-
- static bool IsValidEnqueueOrder(EnqueueOrder enqueue_order) {
- return enqueue_order != 0ull;
- }
+ EnqueueOrder GenerateNext(base::TimeTicks delayed_run_time);
private:
base::Lock lock_;
- EnqueueOrder enqueue_order_;
+ uint64_t sequence_num_;
};
} // namespace internal

Powered by Google App Engine
This is Rietveld 408576698