Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1205)

Unified Diff: base/threading/platform_thread_win.cc

Issue 12741012: base: Support setting thread priorities generically. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove static initializers. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/threading/platform_thread_unittest.cc ('k') | base/threading/thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/platform_thread_win.cc
diff --git a/base/threading/platform_thread_win.cc b/base/threading/platform_thread_win.cc
index 9e877b32f9e1e630ce31c164f5e58680b898e5f7..904f2b4d27ebc042392c22e08e7f9cc272c0b23d 100644
--- a/base/threading/platform_thread_win.cc
+++ b/base/threading/platform_thread_win.cc
@@ -64,7 +64,6 @@ DWORD __stdcall ThreadFunc(void* params) {
bool CreateThreadInternal(size_t stack_size,
PlatformThread::Delegate* delegate,
PlatformThreadHandle* out_thread_handle) {
- PlatformThreadHandle thread_handle;
unsigned int flags = 0;
if (stack_size > 0 && base::win::GetVersion() >= base::win::VERSION_XP) {
flags = STACK_SIZE_PARAM_IS_A_RESERVATION;
@@ -81,7 +80,7 @@ bool CreateThreadInternal(size_t stack_size,
// have to work running on CreateThread() threads anyway, since we run code
// on the Windows thread pool, etc. For some background on the difference:
// http://www.microsoft.com/msj/1099/win32/win321099.aspx
- thread_handle = CreateThread(
+ void* thread_handle = CreateThread(
NULL, stack_size, ThreadFunc, params, flags, NULL);
if (!thread_handle) {
delete params;
@@ -89,7 +88,7 @@ bool CreateThreadInternal(size_t stack_size,
}
if (out_thread_handle)
- *out_thread_handle = thread_handle;
+ *out_thread_handle = PlatformThreadHandle(thread_handle);
else
CloseHandle(thread_handle);
return true;
@@ -103,6 +102,12 @@ PlatformThreadId PlatformThread::CurrentId() {
}
// static
+PlatformThreadHandle PlatformThread::CurrentHandle() {
+ NOTIMPLEMENTED(); // See OpenThread()
+ return PlatformThreadHandle();
+}
+
+// static
void PlatformThread::YieldCurrentThread() {
::Sleep(0);
}
@@ -164,7 +169,7 @@ bool PlatformThread::CreateNonJoinable(size_t stack_size, Delegate* delegate) {
// static
void PlatformThread::Join(PlatformThreadHandle thread_handle) {
- DCHECK(thread_handle);
+ DCHECK(thread_handle.handle_);
// TODO(willchan): Enable this check once I can get it to work for Windows
// shutdown.
// Joining another thread may block the current thread for a long time, since
@@ -176,17 +181,17 @@ void PlatformThread::Join(PlatformThreadHandle thread_handle) {
// Wait for the thread to exit. It should already have terminated but make
// sure this assumption is valid.
- DWORD result = WaitForSingleObject(thread_handle, INFINITE);
+ DWORD result = WaitForSingleObject(thread_handle.handle_, INFINITE);
if (result != WAIT_OBJECT_0) {
// Debug info for bug 127931.
DWORD error = GetLastError();
debug::Alias(&error);
debug::Alias(&result);
- debug::Alias(&thread_handle);
+ debug::Alias(&thread_handle.handle_);
CHECK(false);
}
- CloseHandle(thread_handle);
+ CloseHandle(thread_handle.handle_);
}
// static
@@ -194,10 +199,13 @@ void PlatformThread::SetThreadPriority(PlatformThreadHandle handle,
ThreadPriority priority) {
switch (priority) {
case kThreadPriority_Normal:
- ::SetThreadPriority(handle, THREAD_PRIORITY_NORMAL);
+ ::SetThreadPriority(handle.handle_, THREAD_PRIORITY_NORMAL);
break;
case kThreadPriority_RealtimeAudio:
- ::SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL);
+ ::SetThreadPriority(handle.handle_, THREAD_PRIORITY_TIME_CRITICAL);
+ break;
+ default:
+ NOTREACHED() << "Unknown priority.";
break;
}
}
« no previous file with comments | « base/threading/platform_thread_unittest.cc ('k') | base/threading/thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698