summaryrefslogtreecommitdiffstats
path: root/base/threading/platform_thread_win.cc
diff options
context:
space:
mode:
Diffstat (limited to 'base/threading/platform_thread_win.cc')
-rw-r--r--base/threading/platform_thread_win.cc26
1 files changed, 17 insertions, 9 deletions
diff --git a/base/threading/platform_thread_win.cc b/base/threading/platform_thread_win.cc
index 9e877b3..904f2b4 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;
}
}