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

Side by Side Diff: Source/wtf/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: Adding wtf/DoubleBufferedDeque.h to git 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 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 #ifndef DoubleBufferedDeque_h
6 #define DoubleBufferedDeque_h
7
8 #include "wtf/Deque.h"
9 #include "wtf/Noncopyable.h"
10
11 namespace WTF {
12
13 template <typename T> class DoubleBufferedDeque {
14 WTF_MAKE_NONCOPYABLE(DoubleBufferedDeque);
15 public:
16 DoubleBufferedDeque()
17 : m_activeIndex(0) { }
18
19 void append(const T& value)
20 {
21 m_queue[m_activeIndex].append(value);
22 }
23
24 WTF::Deque<T>& swapBuffers()
25 {
26 int oldIndex = m_activeIndex;
27 m_activeIndex ^= 1;
28 ASSERT(m_queue[m_activeIndex].isEmpty());
29 return m_queue[oldIndex];
30 }
31
32 private:
33 WTF::Deque<T> m_queue[2];
34 int m_activeIndex;
35 };
36
37 } // namespace WTF
38
39 using WTF::DoubleBufferedDeque
40
41 #endif // DoubleBufferedDeque_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698