From 0e37e6dfee6954e50b0d7eb2092f0096f83b2e98 Mon Sep 17 00:00:00 2001 From: Chris Thrasher Date: Fri, 25 Oct 2024 16:35:41 -0600 Subject: [PATCH] Use `std::queue` to model queues --- examples/island/Island.cpp | 8 ++++---- src/SFML/Window/Unix/ClipboardImpl.cpp | 4 ++-- src/SFML/Window/Unix/ClipboardImpl.hpp | 4 ++-- src/SFML/Window/Unix/WindowImplX11.hpp | 1 - 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/examples/island/Island.cpp b/examples/island/Island.cpp index 628c17c52..e5cc41972 100644 --- a/examples/island/Island.cpp +++ b/examples/island/Island.cpp @@ -8,9 +8,9 @@ #include #include -#include #include #include +#include #include #include #include @@ -40,7 +40,7 @@ struct WorkItem unsigned int index{}; }; -std::deque workQueue; +std::queue workQueue; std::vector threads; int pendingWorkCount = 0; bool workPending = true; @@ -356,7 +356,7 @@ void threadFunction() if (!workQueue.empty()) { workItem = workQueue.front(); - workQueue.pop_front(); + workQueue.pop(); } } @@ -409,7 +409,7 @@ void generateTerrain(sf::Vertex* buffer) for (unsigned int i = 0; i < blockCount; ++i) { const WorkItem workItem = {buffer, i}; - workQueue.push_back(workItem); + workQueue.push(workItem); } pendingWorkCount = blockCount; diff --git a/src/SFML/Window/Unix/ClipboardImpl.cpp b/src/SFML/Window/Unix/ClipboardImpl.cpp index 89f6c2f4e..ebd3f8e84 100644 --- a/src/SFML/Window/Unix/ClipboardImpl.cpp +++ b/src/SFML/Window/Unix/ClipboardImpl.cpp @@ -175,13 +175,13 @@ void ClipboardImpl::processEventsImpl() // Pick out the events that are interesting for this window while (XCheckIfEvent(m_display.get(), &event, &checkEvent, reinterpret_cast(m_window))) - m_events.push_back(event); + m_events.push(event); // Handle the events for this window that we just picked out while (!m_events.empty()) { event = m_events.front(); - m_events.pop_front(); + m_events.pop(); processEvent(event); } } diff --git a/src/SFML/Window/Unix/ClipboardImpl.hpp b/src/SFML/Window/Unix/ClipboardImpl.hpp index d39910b82..8d6f345ef 100644 --- a/src/SFML/Window/Unix/ClipboardImpl.hpp +++ b/src/SFML/Window/Unix/ClipboardImpl.hpp @@ -33,8 +33,8 @@ #include -#include #include +#include namespace sf::priv @@ -143,7 +143,7 @@ private: Atom m_utf8String; ///< X Atom identifying UTF8_STRING Atom m_targetProperty; ///< X Atom identifying our destination window property String m_clipboardContents; ///< Our clipboard contents - std::deque m_events; ///< Queue we use to store pending events for this window + std::queue m_events; ///< Queue we use to store pending events for this window bool m_requestResponded{}; ///< Holds whether our selection request has been responded to or not }; diff --git a/src/SFML/Window/Unix/WindowImplX11.hpp b/src/SFML/Window/Unix/WindowImplX11.hpp index ad0c6f8ec..977d95f24 100644 --- a/src/SFML/Window/Unix/WindowImplX11.hpp +++ b/src/SFML/Window/Unix/WindowImplX11.hpp @@ -34,7 +34,6 @@ #include #include -#include #include