From 305168d2bb21ffa90555361f677b5e77ef79fc9a Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Thu, 15 Nov 2018 12:17:18 +0100 Subject: [PATCH] [util] Add method to set thread priority --- src/util/thread.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/util/thread.h b/src/util/thread.h index f0c89483..c96cb1c0 100644 --- a/src/util/thread.h +++ b/src/util/thread.h @@ -11,6 +11,17 @@ namespace dxvk { + /** + * \brief Thread priority + */ + enum class ThreadPriority : int32_t { + Lowest = THREAD_PRIORITY_LOWEST, + Low = THREAD_PRIORITY_BELOW_NORMAL, + Normal = THREAD_PRIORITY_NORMAL, + High = THREAD_PRIORITY_ABOVE_NORMAL, + Highest = THREAD_PRIORITY_HIGHEST, + }; + /** * \brief Thread helper class * @@ -56,6 +67,10 @@ namespace dxvk { return m_handle != nullptr; } + void set_priority(ThreadPriority priority) { + ::SetThreadPriority(m_handle, int32_t(priority)); + } + private: Proc m_proc; @@ -106,6 +121,10 @@ namespace dxvk { return m_thread != nullptr && m_thread->joinable(); } + + void set_priority(ThreadPriority priority) { + m_thread->set_priority(priority); + } static uint32_t hardware_concurrency() { SYSTEM_INFO info = { };