Index: base/threading/platform_thread_win.cc |
diff --git a/base/threading/platform_thread_win.cc b/base/threading/platform_thread_win.cc |
index 395fc9e20173ad00797c85248584a9d7d1826d7d..c2eab6ccfd3e7462ec9816dee32ef54204c0f3f7 100644 |
--- a/base/threading/platform_thread_win.cc |
+++ b/base/threading/platform_thread_win.cc |
@@ -46,6 +46,7 @@ void SetNameInternal(PlatformThreadId thread_id, const char* name) { |
struct ThreadParams { |
PlatformThread::Delegate* delegate; |
bool joinable; |
+ ThreadPriority priority; |
}; |
DWORD __stdcall ThreadFunc(void* params) { |
@@ -54,6 +55,11 @@ DWORD __stdcall ThreadFunc(void* params) { |
if (!thread_params->joinable) |
base::ThreadRestrictions::SetSingletonAllowed(false); |
+ if (thread_params->priority != ThreadPriority::NORMAL) { |
+ PlatformThread::SetThreadPriority( |
+ PlatformThread::CurrentHandle(), thread_params->priority); |
+ } |
+ |
// Retrieve a copy of the thread handle to use as the key in the |
// thread name mapping. |
PlatformThreadHandle::Handle platform_handle; |
@@ -86,12 +92,13 @@ DWORD __stdcall ThreadFunc(void* params) { |
return NULL; |
} |
-// CreateThreadInternal() matches PlatformThread::Create(), except that |
-// |out_thread_handle| may be NULL, in which case a non-joinable thread is |
+// CreateThreadInternal() matches PlatformThread::CreateWithPriority(), except |
+// that |out_thread_handle| may be NULL, in which case a non-joinable thread is |
// created. |
bool CreateThreadInternal(size_t stack_size, |
PlatformThread::Delegate* delegate, |
- PlatformThreadHandle* out_thread_handle) { |
+ PlatformThreadHandle* out_thread_handle, |
+ ThreadPriority priority) { |
unsigned int flags = 0; |
if (stack_size > 0 && base::win::GetVersion() >= base::win::VERSION_XP) { |
flags = STACK_SIZE_PARAM_IS_A_RESERVATION; |
@@ -102,6 +109,7 @@ bool CreateThreadInternal(size_t stack_size, |
ThreadParams* params = new ThreadParams; |
params->delegate = delegate; |
params->joinable = out_thread_handle != NULL; |
+ params->priority = priority; |
// Using CreateThread here vs _beginthreadex makes thread creation a bit |
// faster and doesn't require the loader lock to be available. Our code will |
@@ -185,23 +193,22 @@ const char* PlatformThread::GetName() { |
// static |
bool PlatformThread::Create(size_t stack_size, Delegate* delegate, |
PlatformThreadHandle* thread_handle) { |
- DCHECK(thread_handle); |
- return CreateThreadInternal(stack_size, delegate, thread_handle); |
+ return CreateWithPriority( |
+ stack_size, delegate, thread_handle, ThreadPriority::NORMAL); |
} |
// static |
bool PlatformThread::CreateWithPriority(size_t stack_size, Delegate* delegate, |
PlatformThreadHandle* thread_handle, |
ThreadPriority priority) { |
- bool result = Create(stack_size, delegate, thread_handle); |
- if (result) |
- SetThreadPriority(*thread_handle, priority); |
- return result; |
+ DCHECK(thread_handle); |
+ return CreateThreadInternal(stack_size, delegate, thread_handle, priority); |
} |
// static |
bool PlatformThread::CreateNonJoinable(size_t stack_size, Delegate* delegate) { |
- return CreateThreadInternal(stack_size, delegate, NULL); |
+ return CreateThreadInternal( |
+ stack_size, delegate, NULL, ThreadPriority::NORMAL); |
} |
// static |