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

Unified Diff: third_party/WebKit/Source/wtf/Deque.h

Issue 2579773002: Use WTF::Deque instead of std::queue in the blink scheduler (Closed)
Patch Set: Add some STL naming compatability wrappers to WTF::Deque these all get inlined away by the compiler. Created 3 years, 11 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/wtf/Deque.h
diff --git a/third_party/WebKit/Source/wtf/Deque.h b/third_party/WebKit/Source/wtf/Deque.h
index f244bb52846c86533603a7947db9d2ac2b2e15b3..7937801026b1073a016ce3a60fa20a88fe1a7351 100644
--- a/third_party/WebKit/Source/wtf/Deque.h
+++ b/third_party/WebKit/Source/wtf/Deque.h
@@ -134,6 +134,27 @@ class Deque : public ConditionalDestructor<Deque<T, INLINE_CAPACITY, Allocator>,
void remove(iterator&);
void remove(const_iterator&);
+ // STL compatibility.
+ template <typename U>
+ void push_back(U&& u) {
+ append(std::forward<U>(u));
+ }
+ template <typename U>
+ void push_front(U&& u) {
+ prepend(std::forward<U>(u));
+ }
+ void pop_back() { removeLast(); }
+ void pop_front() { removeFirst(); }
+ bool empty() const { return isEmpty(); }
+ T& front() { return first(); }
+ const T& front() const { return first(); }
+ T& back() { return last(); }
+ const T& back() const { return last(); }
+ template <typename... Args>
+ void emplace_back(Args&&...);
+ template <typename... Args>
+ void emplace_front(Args&&...);
+
void clear();
template <typename VisitorDispatcher>
@@ -504,6 +525,28 @@ inline void Deque<T, inlineCapacity, Allocator>::prepend(U&& value) {
}
template <typename T, size_t inlineCapacity, typename Allocator>
+template <typename... Args>
+inline void Deque<T, inlineCapacity, Allocator>::emplace_back(Args&&... args) {
+ expandCapacityIfNeeded();
+ new (NotNull, &m_buffer.buffer()[m_end]) T(std::forward<Args>(args)...);
+ if (m_end == m_buffer.capacity() - 1)
Sami 2017/01/11 13:49:11 Looks like this already exists with the current co
alex clarke (OOO till 29th) 2017/01/11 14:04:26 Done.
+ m_end = 0;
+ else
+ ++m_end;
+}
+
+template <typename T, size_t inlineCapacity, typename Allocator>
+template <typename... Args>
+inline void Deque<T, inlineCapacity, Allocator>::emplace_front(Args&&... args) {
+ expandCapacityIfNeeded();
+ if (!m_start)
+ m_start = m_buffer.capacity() - 1;
+ else
+ --m_start;
+ new (NotNull, &m_buffer.buffer()[m_start]) T(std::forward<Args>(args)...);
+}
+
+template <typename T, size_t inlineCapacity, typename Allocator>
inline void Deque<T, inlineCapacity, Allocator>::removeFirst() {
DCHECK(!isEmpty());
TypeOperations::destruct(&m_buffer.buffer()[m_start],
« no previous file with comments | « third_party/WebKit/Source/platform/scheduler/base/work_queue_unittest.cc ('k') | third_party/WebKit/Source/wtf/DequeTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698