summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorScott Mansell <phiren@gmail.com>2023-02-04 11:31:49 +1300
committerScott Mansell <phiren@gmail.com>2023-02-04 14:58:12 +1300
commitacdb0c5be12ae3db1f09283a0d491fe07f178683 (patch)
tree43c88db01188ba93c4efb53b6dd02bf01c620753 /Source
parent94a0c50bf889dea188f1993202657e8f202a302c (diff)
WorkQueueThread: Implement thread name
Otherwise we will end up with a dozen threads named "WorkQueueThread"
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Common/WorkQueueThread.h11
-rw-r--r--Source/Core/Core/HW/EXI/EXI_DeviceMic.cpp2
-rw-r--r--Source/Core/Core/HW/EXI/EXI_DeviceMic.h2
-rw-r--r--Source/Core/Core/IOS/Network/IP/Top.h2
-rw-r--r--Source/Core/Core/IOS/Network/KD/NetKDRequest.h2
-rw-r--r--Source/Core/Core/State.cpp2
-rw-r--r--Source/Core/DolphinQt/GameList/GameTracker.h2
7 files changed, 14 insertions, 9 deletions
diff --git a/Source/Core/Common/WorkQueueThread.h b/Source/Core/Common/WorkQueueThread.h
index a6cb71b7f9..c3315ac26f 100644
--- a/Source/Core/Common/WorkQueueThread.h
+++ b/Source/Core/Common/WorkQueueThread.h
@@ -5,6 +5,7 @@
#include <functional>
#include <queue>
+#include <string>
#include <thread>
#include "Common/Event.h"
@@ -19,8 +20,11 @@ template <typename T>
class WorkQueueThread
{
public:
- WorkQueueThread() = default;
- WorkQueueThread(std::function<void(T)> function) { Reset(std::move(function)); }
+ WorkQueueThread(std::string name) : m_thread_name(name){};
+ WorkQueueThread(std::function<void(T)> function, std::string name) : m_thread_name(name)
+ {
+ Reset(std::move(function));
+ }
~WorkQueueThread() { Shutdown(); }
void Reset(std::function<void(T)> function)
{
@@ -139,7 +143,7 @@ public:
private:
void ThreadLoop()
{
- Common::SetCurrentThreadName("WorkQueueThread");
+ Common::SetCurrentThreadName(m_thread_name.c_str());
while (true)
{
@@ -166,6 +170,7 @@ private:
}
std::function<void(T)> m_function;
+ std::string m_thread_name;
std::thread m_thread;
std::mutex m_lock;
std::queue<T> m_items;
diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceMic.cpp b/Source/Core/Core/HW/EXI/EXI_DeviceMic.cpp
index 31de1ddb5a..7aac4177b5 100644
--- a/Source/Core/Core/HW/EXI/EXI_DeviceMic.cpp
+++ b/Source/Core/Core/HW/EXI/EXI_DeviceMic.cpp
@@ -200,7 +200,7 @@ CEXIMic::CEXIMic(int index)
: slot(index)
#ifdef _WIN32
,
- m_work_queue([](const std::function<void()>& func) { func(); })
+ m_work_queue([](const std::function<void()>& func) { func(); }, "Mic Worker")
#endif
{
m_position = 0;
diff --git a/Source/Core/Core/HW/EXI/EXI_DeviceMic.h b/Source/Core/Core/HW/EXI/EXI_DeviceMic.h
index a831ef33e5..937665525b 100644
--- a/Source/Core/Core/HW/EXI/EXI_DeviceMic.h
+++ b/Source/Core/Core/HW/EXI/EXI_DeviceMic.h
@@ -102,7 +102,7 @@ private:
int samples_avail;
#ifdef _WIN32
- Common::WorkQueueThread<std::function<void()>> m_work_queue;
+ Common::WorkQueueThread<std::function<void()>> m_work_queue{"Mic Worker"};
bool m_coinit_success = false;
bool m_should_couninit = false;
#endif
diff --git a/Source/Core/Core/IOS/Network/IP/Top.h b/Source/Core/Core/IOS/Network/IP/Top.h
index cc41180860..1e5f86cb29 100644
--- a/Source/Core/Core/IOS/Network/IP/Top.h
+++ b/Source/Core/Core/IOS/Network/IP/Top.h
@@ -120,7 +120,7 @@ private:
IPCReply HandleICMPPingRequest(const IOCtlVRequest& request);
Common::SocketContext m_socket_context;
- Common::WorkQueueThread<AsyncTask> m_work_queue;
+ Common::WorkQueueThread<AsyncTask> m_work_queue{"Network Worker"};
std::mutex m_async_reply_lock;
std::queue<AsyncReply> m_async_replies;
};
diff --git a/Source/Core/Core/IOS/Network/KD/NetKDRequest.h b/Source/Core/Core/IOS/Network/KD/NetKDRequest.h
index aae52a11f5..8d2cb9153c 100644
--- a/Source/Core/Core/IOS/Network/KD/NetKDRequest.h
+++ b/Source/Core/Core/IOS/Network/KD/NetKDRequest.h
@@ -54,7 +54,7 @@ private:
NWC24::NWC24Config config;
NWC24::NWC24Dl m_dl_list;
- Common::WorkQueueThread<AsyncTask> m_work_queue;
+ Common::WorkQueueThread<AsyncTask> m_work_queue{"WiiConnect24 Worker"};
std::mutex m_async_reply_lock;
std::queue<AsyncReply> m_async_replies;
// TODO: Maybe move away from Common::HttpRequest?
diff --git a/Source/Core/Core/State.cpp b/Source/Core/Core/State.cpp
index 405af72f4a..f045afadb5 100644
--- a/Source/Core/Core/State.cpp
+++ b/Source/Core/Core/State.cpp
@@ -85,7 +85,7 @@ struct CompressAndDumpState_args
static std::mutex s_save_thread_mutex;
// Queue for compressing and writing savestates to disk.
-static Common::WorkQueueThread<CompressAndDumpState_args> s_save_thread;
+static Common::WorkQueueThread<CompressAndDumpState_args> s_save_thread("Savestate Worker");
// Keeps track of savestate writes that are currently happening, so we don't load a state while
// another one is still saving. This is particularly important so if you save to a slot and then
diff --git a/Source/Core/DolphinQt/GameList/GameTracker.h b/Source/Core/DolphinQt/GameList/GameTracker.h
index 97ec5bb268..1cfd02e62a 100644
--- a/Source/Core/DolphinQt/GameList/GameTracker.h
+++ b/Source/Core/DolphinQt/GameList/GameTracker.h
@@ -87,7 +87,7 @@ private:
// game path -> directories that track it
QMap<QString, QSet<QString>> m_tracked_files;
QVector<QString> m_tracked_paths;
- Common::WorkQueueThread<Command> m_load_thread;
+ Common::WorkQueueThread<Command> m_load_thread{"GameList Tracker"};
UICommon::GameFileCache m_cache;
Common::Event m_cache_loaded_event;
Common::Event m_initial_games_emitted_event;