diff options
| author | Scott Mansell <phiren@gmail.com> | 2023-02-04 15:56:27 +1300 |
|---|---|---|
| committer | Scott Mansell <phiren@gmail.com> | 2023-02-04 15:56:27 +1300 |
| commit | 7c4fcc30a369763b9fd5f04964d275c707fb17c2 (patch) | |
| tree | 3e4c3381e4264b81b183caaf40e5033c641d50f0 /Source/Core/Common/WorkQueueThread.h | |
| parent | 6594532f103f85d2dc7362506040b3c25cbacb42 (diff) | |
WorkQueueThread: provide name and function at same time
Diffstat (limited to 'Source/Core/Common/WorkQueueThread.h')
| -rw-r--r-- | Source/Core/Common/WorkQueueThread.h | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Source/Core/Common/WorkQueueThread.h b/Source/Core/Common/WorkQueueThread.h index f7c70edee8..74074a326a 100644 --- a/Source/Core/Common/WorkQueueThread.h +++ b/Source/Core/Common/WorkQueueThread.h @@ -20,19 +20,20 @@ template <typename T> class WorkQueueThread { public: - WorkQueueThread(std::string name) : m_thread_name(name){}; - WorkQueueThread(std::function<void(T)> function, std::string name) : m_thread_name(name) + WorkQueueThread() = default; + WorkQueueThread(const std::string name, std::function<void(T)> function) { - Reset(std::move(function)); + Reset(std::move(name), std::move(function)); } ~WorkQueueThread() { Shutdown(); } // Shuts the current work thread down (if any) and starts a new thread with the given function // Note: Some consumers of this API push items to the queue before starting the thread. - void Reset(std::function<void(T)> function) + void Reset(const std::string& name, std::function<void(T)> function) { Shutdown(); std::lock_guard lg(m_lock); + m_thread_name = std::move(name); m_shutdown = false; m_function = std::move(function); m_thread = std::thread(&WorkQueueThread::ThreadLoop, this); |
