diff options
| author | Scott Mansell <phiren@gmail.com> | 2023-02-04 11:31:49 +1300 |
|---|---|---|
| committer | Scott Mansell <phiren@gmail.com> | 2023-02-04 14:58:12 +1300 |
| commit | acdb0c5be12ae3db1f09283a0d491fe07f178683 (patch) | |
| tree | 43c88db01188ba93c4efb53b6dd02bf01c620753 /Source/Core/Common/WorkQueueThread.h | |
| parent | 94a0c50bf889dea188f1993202657e8f202a302c (diff) | |
WorkQueueThread: Implement thread name
Otherwise we will end up with a dozen threads named "WorkQueueThread"
Diffstat (limited to 'Source/Core/Common/WorkQueueThread.h')
| -rw-r--r-- | Source/Core/Common/WorkQueueThread.h | 11 |
1 files changed, 8 insertions, 3 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; |
