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

Unified Diff: Source/platform/scheduler/DoubleBufferedDeque.h

Issue 439923006: Prioritizing input and compositor tasks in the blink scheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase + respond to Eric's feedback Created 6 years, 4 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
« no previous file with comments | « Source/platform/blink_platform.gypi ('k') | Source/platform/scheduler/DoubleBufferedDequeTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/scheduler/DoubleBufferedDeque.h
diff --git a/Source/platform/scheduler/DoubleBufferedDeque.h b/Source/platform/scheduler/DoubleBufferedDeque.h
new file mode 100644
index 0000000000000000000000000000000000000000..404982972a80115a9227192bcd45603dc5cd2c6d
--- /dev/null
+++ b/Source/platform/scheduler/DoubleBufferedDeque.h
@@ -0,0 +1,44 @@
+// Copyright 2014 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 DoubleBufferedDeque_h
+#define DoubleBufferedDeque_h
+
+#include "wtf/Deque.h"
+#include "wtf/Noncopyable.h"
+
+namespace blink {
+
+template <typename T> class DoubleBufferedDeque {
eseidel 2014/08/11 15:19:14 Base datatypes like this probably belong in wtf.
alexclarke 2014/08/12 11:37:02 Done.
+ WTF_MAKE_NONCOPYABLE(DoubleBufferedDeque);
+public:
+ DoubleBufferedDeque()
+ : m_activeIndex(0) { }
+
+ void append(const T& value)
+ {
+ m_queue[m_activeIndex].append(value);
+ }
+
+ bool isEmpty()
+ {
+ return m_queue[m_activeIndex].isEmpty();
+ }
+
+ WTF::Deque<T>& swapBuffers()
+ {
+ int oldIndex = m_activeIndex;
+ m_activeIndex ^= 1;
+ ASSERT(m_queue[m_activeIndex].isEmpty());
+ return m_queue[oldIndex];
+ }
+
+private:
+ WTF::Deque<T> m_queue[2];
+ int m_activeIndex;
+};
+
+} // namespace blink
+
+#endif // DoubleBufferedDeque_h
« no previous file with comments | « Source/platform/blink_platform.gypi ('k') | Source/platform/scheduler/DoubleBufferedDequeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698