Use std::queue to model queues

This commit is contained in:
Chris Thrasher 2024-10-25 16:35:41 -06:00
parent 08bfae34e7
commit 0e37e6dfee
4 changed files with 8 additions and 9 deletions

View File

@ -8,9 +8,9 @@
#include <algorithm>
#include <array>
#include <deque>
#include <iostream>
#include <mutex>
#include <queue>
#include <sstream>
#include <thread>
#include <vector>
@ -40,7 +40,7 @@ struct WorkItem
unsigned int index{};
};
std::deque<WorkItem> workQueue;
std::queue<WorkItem> workQueue;
std::vector<std::thread> 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;

View File

@ -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<XPointer>(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);
}
}

View File

@ -33,8 +33,8 @@
#include <X11/Xlib.h>
#include <deque>
#include <memory>
#include <queue>
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<XEvent> m_events; ///< Queue we use to store pending events for this window
std::queue<XEvent> 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
};

View File

@ -34,7 +34,6 @@
#include <X11/Xlib.h>
#include <X11/extensions/Xrandr.h>
#include <deque>
#include <memory>