mirror of
https://github.com/SFML/SFML.git
synced 2025-01-31 13:45:13 +08:00
Use std::queue
to model queues
This commit is contained in:
parent
08bfae34e7
commit
0e37e6dfee
@ -8,9 +8,9 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <deque>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <queue>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -40,7 +40,7 @@ struct WorkItem
|
|||||||
unsigned int index{};
|
unsigned int index{};
|
||||||
};
|
};
|
||||||
|
|
||||||
std::deque<WorkItem> workQueue;
|
std::queue<WorkItem> workQueue;
|
||||||
std::vector<std::thread> threads;
|
std::vector<std::thread> threads;
|
||||||
int pendingWorkCount = 0;
|
int pendingWorkCount = 0;
|
||||||
bool workPending = true;
|
bool workPending = true;
|
||||||
@ -356,7 +356,7 @@ void threadFunction()
|
|||||||
if (!workQueue.empty())
|
if (!workQueue.empty())
|
||||||
{
|
{
|
||||||
workItem = workQueue.front();
|
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)
|
for (unsigned int i = 0; i < blockCount; ++i)
|
||||||
{
|
{
|
||||||
const WorkItem workItem = {buffer, i};
|
const WorkItem workItem = {buffer, i};
|
||||||
workQueue.push_back(workItem);
|
workQueue.push(workItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
pendingWorkCount = blockCount;
|
pendingWorkCount = blockCount;
|
||||||
|
@ -175,13 +175,13 @@ void ClipboardImpl::processEventsImpl()
|
|||||||
|
|
||||||
// Pick out the events that are interesting for this window
|
// Pick out the events that are interesting for this window
|
||||||
while (XCheckIfEvent(m_display.get(), &event, &checkEvent, reinterpret_cast<XPointer>(m_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
|
// Handle the events for this window that we just picked out
|
||||||
while (!m_events.empty())
|
while (!m_events.empty())
|
||||||
{
|
{
|
||||||
event = m_events.front();
|
event = m_events.front();
|
||||||
m_events.pop_front();
|
m_events.pop();
|
||||||
processEvent(event);
|
processEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,8 @@
|
|||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
#include <deque>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <queue>
|
||||||
|
|
||||||
|
|
||||||
namespace sf::priv
|
namespace sf::priv
|
||||||
@ -143,7 +143,7 @@ private:
|
|||||||
Atom m_utf8String; ///< X Atom identifying UTF8_STRING
|
Atom m_utf8String; ///< X Atom identifying UTF8_STRING
|
||||||
Atom m_targetProperty; ///< X Atom identifying our destination window property
|
Atom m_targetProperty; ///< X Atom identifying our destination window property
|
||||||
String m_clipboardContents; ///< Our clipboard contents
|
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
|
bool m_requestResponded{}; ///< Holds whether our selection request has been responded to or not
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/extensions/Xrandr.h>
|
#include <X11/extensions/Xrandr.h>
|
||||||
|
|
||||||
#include <deque>
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user