| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/platform_thread.h" | 5 #include "base/platform_thread.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/win_util.h" | 8 #include "base/win_util.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // faster and doesn't require the loader lock to be available. Our code will | 78 // faster and doesn't require the loader lock to be available. Our code will |
| 79 // have to work running on CreateThread() threads anyway, since we run code | 79 // have to work running on CreateThread() threads anyway, since we run code |
| 80 // on the Windows thread pool, etc. For some background on the difference: | 80 // on the Windows thread pool, etc. For some background on the difference: |
| 81 // http://www.microsoft.com/msj/1099/win32/win321099.aspx | 81 // http://www.microsoft.com/msj/1099/win32/win321099.aspx |
| 82 *thread_handle = CreateThread( | 82 *thread_handle = CreateThread( |
| 83 NULL, stack_size, ThreadFunc, delegate, flags, NULL); | 83 NULL, stack_size, ThreadFunc, delegate, flags, NULL); |
| 84 return *thread_handle != NULL; | 84 return *thread_handle != NULL; |
| 85 } | 85 } |
| 86 | 86 |
| 87 // static | 87 // static |
| 88 bool PlatformThread::CreateNonJoinable(size_t stack_size, Delegate* delegate) { |
| 89 PlatformThreadHandle thread_handle; |
| 90 bool result = Create(stack_size, delegate, &thread_handle); |
| 91 CloseHandle(thread_handle); |
| 92 return result; |
| 93 } |
| 94 |
| 95 // static |
| 88 void PlatformThread::Join(PlatformThreadHandle thread_handle) { | 96 void PlatformThread::Join(PlatformThreadHandle thread_handle) { |
| 89 DCHECK(thread_handle); | 97 DCHECK(thread_handle); |
| 90 | 98 |
| 91 // Wait for the thread to exit. It should already have terminated but make | 99 // Wait for the thread to exit. It should already have terminated but make |
| 92 // sure this assumption is valid. | 100 // sure this assumption is valid. |
| 93 DWORD result = WaitForSingleObject(thread_handle, INFINITE); | 101 DWORD result = WaitForSingleObject(thread_handle, INFINITE); |
| 94 DCHECK_EQ(WAIT_OBJECT_0, result); | 102 DCHECK_EQ(WAIT_OBJECT_0, result); |
| 95 | 103 |
| 96 CloseHandle(thread_handle); | 104 CloseHandle(thread_handle); |
| 97 } | 105 } |
| OLD | NEW |