Merge pull request #5973 from ligfx/renamefifoqueue

Rename Common::FifoQueue to Common::SPSCQueue
This commit is contained in:
JosJuice 2017-11-19 13:51:22 +01:00 committed by GitHub
commit b8c83dd5f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 35 additions and 35 deletions

View File

@ -14,9 +14,9 @@
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/Event.h" #include "Common/Event.h"
#include "Common/FifoQueue.h"
#include "Common/Flag.h" #include "Common/Flag.h"
#include "Common/HttpRequest.h" #include "Common/HttpRequest.h"
#include "Common/SPSCQueue.h"
// Utilities for analytics reporting in Dolphin. This reporting is designed to // Utilities for analytics reporting in Dolphin. This reporting is designed to
// provide anonymous data about how well Dolphin performs in the wild. It also // provide anonymous data about how well Dolphin performs in the wild. It also
@ -157,7 +157,7 @@ protected:
std::thread m_reporter_thread; std::thread m_reporter_thread;
Common::Event m_reporter_event; Common::Event m_reporter_event;
Common::Flag m_reporter_stop_request; Common::Flag m_reporter_stop_request;
FifoQueue<std::string> m_reports_queue; SPSCQueue<std::string> m_reports_queue;
}; };
// Analytics backend to be used for debugging purpose, which dumps reports to // Analytics backend to be used for debugging purpose, which dumps reports to

View File

@ -62,7 +62,6 @@
<ClInclude Include="DebugInterface.h" /> <ClInclude Include="DebugInterface.h" />
<ClInclude Include="ENetUtil.h" /> <ClInclude Include="ENetUtil.h" />
<ClInclude Include="Event.h" /> <ClInclude Include="Event.h" />
<ClInclude Include="FifoQueue.h" />
<ClInclude Include="File.h" /> <ClInclude Include="File.h" />
<ClInclude Include="FileSearch.h" /> <ClInclude Include="FileSearch.h" />
<ClInclude Include="FileUtil.h" /> <ClInclude Include="FileUtil.h" />
@ -142,6 +141,7 @@
<ClInclude Include="SDCardUtil.h" /> <ClInclude Include="SDCardUtil.h" />
<ClInclude Include="Semaphore.h" /> <ClInclude Include="Semaphore.h" />
<ClInclude Include="SettingsHandler.h" /> <ClInclude Include="SettingsHandler.h" />
<ClInclude Include="SPSCQueue.h" />
<ClInclude Include="StringUtil.h" /> <ClInclude Include="StringUtil.h" />
<ClInclude Include="Swap.h" /> <ClInclude Include="Swap.h" />
<ClInclude Include="SymbolDB.h" /> <ClInclude Include="SymbolDB.h" />
@ -238,4 +238,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>
</Project> </Project>

View File

@ -41,7 +41,6 @@
<ClInclude Include="CPUDetect.h" /> <ClInclude Include="CPUDetect.h" />
<ClInclude Include="DebugInterface.h" /> <ClInclude Include="DebugInterface.h" />
<ClInclude Include="ENetUtil.h" /> <ClInclude Include="ENetUtil.h" />
<ClInclude Include="FifoQueue.h" />
<ClInclude Include="FileSearch.h" /> <ClInclude Include="FileSearch.h" />
<ClInclude Include="FileUtil.h" /> <ClInclude Include="FileUtil.h" />
<ClInclude Include="FixedSizeQueue.h" /> <ClInclude Include="FixedSizeQueue.h" />
@ -62,6 +61,7 @@
<ClInclude Include="ScopeGuard.h" /> <ClInclude Include="ScopeGuard.h" />
<ClInclude Include="SDCardUtil.h" /> <ClInclude Include="SDCardUtil.h" />
<ClInclude Include="SettingsHandler.h" /> <ClInclude Include="SettingsHandler.h" />
<ClInclude Include="SPSCQueue.h" />
<ClInclude Include="StringUtil.h" /> <ClInclude Include="StringUtil.h" />
<ClInclude Include="Swap.h" /> <ClInclude Include="Swap.h" />
<ClInclude Include="SymbolDB.h" /> <ClInclude Include="SymbolDB.h" />
@ -337,4 +337,4 @@
<ItemGroup> <ItemGroup>
<Natvis Include="BitField.natvis" /> <Natvis Include="BitField.natvis" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -5,7 +5,7 @@
#pragma once #pragma once
// a simple lockless thread-safe, // a simple lockless thread-safe,
// single reader, single writer queue // single producer, single consumer queue
#include <algorithm> #include <algorithm>
#include <atomic> #include <atomic>
@ -16,11 +16,11 @@
namespace Common namespace Common
{ {
template <typename T, bool NeedSize = true> template <typename T, bool NeedSize = true>
class FifoQueue class SPSCQueue
{ {
public: public:
FifoQueue() : m_size(0) { m_write_ptr = m_read_ptr = new ElementPtr(); } SPSCQueue() : m_size(0) { m_write_ptr = m_read_ptr = new ElementPtr(); }
~FifoQueue() ~SPSCQueue()
{ {
// this will empty out the whole queue // this will empty out the whole queue
delete m_read_ptr; delete m_read_ptr;
@ -28,7 +28,7 @@ public:
u32 Size() const u32 Size() const
{ {
static_assert(NeedSize, "using Size() on FifoQueue without NeedSize"); static_assert(NeedSize, "using Size() on SPSCQueue without NeedSize");
return m_size.load(); return m_size.load();
} }

View File

@ -13,8 +13,8 @@
#include "Common/Assert.h" #include "Common/Assert.h"
#include "Common/ChunkFile.h" #include "Common/ChunkFile.h"
#include "Common/FifoQueue.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Common/SPSCQueue.h"
#include "Common/StringUtil.h" #include "Common/StringUtil.h"
#include "Common/Thread.h" #include "Common/Thread.h"
@ -63,7 +63,7 @@ static std::unordered_map<std::string, EventType> s_event_types;
static std::vector<Event> s_event_queue; static std::vector<Event> s_event_queue;
static u64 s_event_fifo_id; static u64 s_event_fifo_id;
static std::mutex s_ts_write_lock; static std::mutex s_ts_write_lock;
static Common::FifoQueue<Event, false> s_ts_queue; static Common::SPSCQueue<Event, false> s_ts_queue;
static float s_last_OC_factor; static float s_last_OC_factor;
static constexpr int MAX_SLICE_LENGTH = 20000; static constexpr int MAX_SLICE_LENGTH = 20000;

View File

@ -16,10 +16,10 @@
#include "Common/ChunkFile.h" #include "Common/ChunkFile.h"
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/Event.h" #include "Common/Event.h"
#include "Common/FifoQueue.h"
#include "Common/Flag.h" #include "Common/Flag.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Common/MsgHandler.h" #include "Common/MsgHandler.h"
#include "Common/SPSCQueue.h"
#include "Common/Thread.h" #include "Common/Thread.h"
#include "Common/Timer.h" #include "Common/Timer.h"
@ -83,8 +83,8 @@ static Common::Event s_request_queue_expanded; // Is set by CPU thread
static Common::Event s_result_queue_expanded; // Is set by DVD thread static Common::Event s_result_queue_expanded; // Is set by DVD thread
static Common::Flag s_dvd_thread_exiting(false); // Is set by CPU thread static Common::Flag s_dvd_thread_exiting(false); // Is set by CPU thread
static Common::FifoQueue<ReadRequest, false> s_request_queue; static Common::SPSCQueue<ReadRequest, false> s_request_queue;
static Common::FifoQueue<ReadResult, false> s_result_queue; static Common::SPSCQueue<ReadResult, false> s_result_queue;
static std::map<u64, ReadResult> s_result_map; static std::map<u64, ReadResult> s_result_map;
static std::unique_ptr<DiscIO::Volume> s_disc; static std::unique_ptr<DiscIO::Volume> s_disc;
@ -139,7 +139,7 @@ void DoState(PointerWrap& p)
WaitUntilIdle(); WaitUntilIdle();
// Move all results from s_result_queue to s_result_map because // Move all results from s_result_queue to s_result_map because
// PointerWrap::Do supports std::map but not Common::FifoQueue. // PointerWrap::Do supports std::map but not Common::SPSCQueue.
// This won't affect the behavior of FinishRead. // This won't affect the behavior of FinishRead.
ReadResult result; ReadResult result;
while (s_result_queue.Pop(result)) while (s_result_queue.Pop(result))

View File

@ -12,8 +12,8 @@
#include "Common/Common.h" #include "Common/Common.h"
#include "Common/Event.h" #include "Common/Event.h"
#include "Common/FifoQueue.h"
#include "Common/Flag.h" #include "Common/Flag.h"
#include "Common/SPSCQueue.h"
#include "Core/HW/Wiimote.h" #include "Core/HW/Wiimote.h"
#include "Core/HW/WiimoteCommon/WiimoteConstants.h" #include "Core/HW/WiimoteCommon/WiimoteConstants.h"
#include "Core/HW/WiimoteCommon/WiimoteHid.h" #include "Core/HW/WiimoteCommon/WiimoteHid.h"
@ -112,8 +112,8 @@ private:
// Triggered when the thread has finished ConnectInternal. // Triggered when the thread has finished ConnectInternal.
Common::Event m_thread_ready_event; Common::Event m_thread_ready_event;
Common::FifoQueue<Report> m_read_reports; Common::SPSCQueue<Report> m_read_reports;
Common::FifoQueue<Report> m_write_reports; Common::SPSCQueue<Report> m_write_reports;
}; };
class WiimoteScannerBackend class WiimoteScannerBackend

View File

@ -13,7 +13,7 @@
#include <vector> #include <vector>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/Event.h" #include "Common/Event.h"
#include "Common/FifoQueue.h" #include "Common/SPSCQueue.h"
#include "Common/TraversalClient.h" #include "Common/TraversalClient.h"
#include "Core/NetPlayProto.h" #include "Core/NetPlayProto.h"
#include "InputCommon/GCPadStatus.h" #include "InputCommon/GCPadStatus.h"
@ -109,10 +109,10 @@ protected:
std::recursive_mutex async_queue_write; std::recursive_mutex async_queue_write;
} m_crit; } m_crit;
Common::FifoQueue<sf::Packet, false> m_async_queue; Common::SPSCQueue<sf::Packet, false> m_async_queue;
std::array<Common::FifoQueue<GCPadStatus>, 4> m_pad_buffer; std::array<Common::SPSCQueue<GCPadStatus>, 4> m_pad_buffer;
std::array<Common::FifoQueue<NetWiimote>, 4> m_wiimote_buffer; std::array<Common::SPSCQueue<NetWiimote>, 4> m_wiimote_buffer;
NetPlayUI* m_dialog = nullptr; NetPlayUI* m_dialog = nullptr;

View File

@ -12,7 +12,7 @@
#include <thread> #include <thread>
#include <unordered_map> #include <unordered_map>
#include <unordered_set> #include <unordered_set>
#include "Common/FifoQueue.h" #include "Common/SPSCQueue.h"
#include "Common/Timer.h" #include "Common/Timer.h"
#include "Common/TraversalClient.h" #include "Common/TraversalClient.h"
#include "Core/NetPlayProto.h" #include "Core/NetPlayProto.h"
@ -114,7 +114,7 @@ private:
std::string m_selected_game; std::string m_selected_game;
std::thread m_thread; std::thread m_thread;
Common::FifoQueue<sf::Packet, false> m_async_queue; Common::SPSCQueue<sf::Packet, false> m_async_queue;
ENetHost* m_server = nullptr; ENetHost* m_server = nullptr;
TraversalClient* m_traversal_client = nullptr; TraversalClient* m_traversal_client = nullptr;

View File

@ -33,9 +33,9 @@
#include "Common/CommonPaths.h" #include "Common/CommonPaths.h"
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/Config/Config.h" #include "Common/Config/Config.h"
#include "Common/FifoQueue.h"
#include "Common/FileUtil.h" #include "Common/FileUtil.h"
#include "Common/MsgHandler.h" #include "Common/MsgHandler.h"
#include "Common/SPSCQueue.h"
#include "Common/StringUtil.h" #include "Common/StringUtil.h"
#include "Core/Config/SYSCONFSettings.h" #include "Core/Config/SYSCONFSettings.h"

View File

@ -9,7 +9,7 @@
#include <wx/frame.h> #include <wx/frame.h>
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/FifoQueue.h" #include "Common/SPSCQueue.h"
#include "Core/NetPlayClient.h" #include "Core/NetPlayClient.h"
#include "Core/NetPlayProto.h" #include "Core/NetPlayProto.h"
#include "Core/NetPlayServer.h" #include "Core/NetPlayServer.h"
@ -161,7 +161,7 @@ private:
std::string m_desync_player; std::string m_desync_player;
std::vector<int> m_playerids; std::vector<int> m_playerids;
Common::FifoQueue<std::string> m_chat_msgs; Common::SPSCQueue<std::string> m_chat_msgs;
const GameListCtrl* const m_game_list; const GameListCtrl* const m_game_list;

View File

@ -5,11 +5,11 @@ add_dolphin_test(BlockingLoopTest BlockingLoopTest.cpp)
add_dolphin_test(BusyLoopTest BusyLoopTest.cpp) add_dolphin_test(BusyLoopTest BusyLoopTest.cpp)
add_dolphin_test(CommonFuncsTest CommonFuncsTest.cpp) add_dolphin_test(CommonFuncsTest CommonFuncsTest.cpp)
add_dolphin_test(EventTest EventTest.cpp) add_dolphin_test(EventTest EventTest.cpp)
add_dolphin_test(FifoQueueTest FifoQueueTest.cpp)
add_dolphin_test(FixedSizeQueueTest FixedSizeQueueTest.cpp) add_dolphin_test(FixedSizeQueueTest FixedSizeQueueTest.cpp)
add_dolphin_test(FlagTest FlagTest.cpp) add_dolphin_test(FlagTest FlagTest.cpp)
add_dolphin_test(MathUtilTest MathUtilTest.cpp) add_dolphin_test(MathUtilTest MathUtilTest.cpp)
add_dolphin_test(NandPathsTest NandPathsTest.cpp) add_dolphin_test(NandPathsTest NandPathsTest.cpp)
add_dolphin_test(SPSCQueueTest SPSCQueueTest.cpp)
add_dolphin_test(StringUtilTest StringUtilTest.cpp) add_dolphin_test(StringUtilTest StringUtilTest.cpp)
add_dolphin_test(SwapTest SwapTest.cpp) add_dolphin_test(SwapTest SwapTest.cpp)
add_dolphin_test(x64EmitterTest x64EmitterTest.cpp) add_dolphin_test(x64EmitterTest x64EmitterTest.cpp)

View File

@ -5,11 +5,11 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <thread> #include <thread>
#include "Common/FifoQueue.h" #include "Common/SPSCQueue.h"
TEST(FifoQueue, Simple) TEST(SPSCQueue, Simple)
{ {
Common::FifoQueue<u32> q; Common::SPSCQueue<u32> q;
EXPECT_EQ(0u, q.Size()); EXPECT_EQ(0u, q.Size());
EXPECT_TRUE(q.Empty()); EXPECT_TRUE(q.Empty());
@ -43,9 +43,9 @@ TEST(FifoQueue, Simple)
EXPECT_TRUE(q.Empty()); EXPECT_TRUE(q.Empty());
} }
TEST(FifoQueue, MultiThreaded) TEST(SPSCQueue, MultiThreaded)
{ {
Common::FifoQueue<u32> q; Common::SPSCQueue<u32> q;
auto inserter = [&q]() { auto inserter = [&q]() {
for (u32 i = 0; i < 100000; ++i) for (u32 i = 0; i < 100000; ++i)