Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/threading/platform_thread.h" | 5 #include "base/threading/platform_thread.h" |
| 6 | 6 |
| 7 #include "base/debug/alias.h" | 7 #include "base/debug/alias.h" |
| 8 #include "base/debug/profiler.h" | 8 #include "base/debug/profiler.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/threading/thread_id_name_manager.h" | 10 #include "base/threading/thread_id_name_manager.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 | 101 |
| 102 ThreadParams* params = new ThreadParams; | 102 ThreadParams* params = new ThreadParams; |
| 103 params->delegate = delegate; | 103 params->delegate = delegate; |
| 104 params->joinable = out_thread_handle != NULL; | 104 params->joinable = out_thread_handle != NULL; |
| 105 | 105 |
| 106 // Using CreateThread here vs _beginthreadex makes thread creation a bit | 106 // Using CreateThread here vs _beginthreadex makes thread creation a bit |
| 107 // faster and doesn't require the loader lock to be available. Our code will | 107 // faster and doesn't require the loader lock to be available. Our code will |
| 108 // have to work running on CreateThread() threads anyway, since we run code | 108 // have to work running on CreateThread() threads anyway, since we run code |
| 109 // on the Windows thread pool, etc. For some background on the difference: | 109 // on the Windows thread pool, etc. For some background on the difference: |
| 110 // http://www.microsoft.com/msj/1099/win32/win321099.aspx | 110 // http://www.microsoft.com/msj/1099/win32/win321099.aspx |
| 111 PlatformThreadId thread_id; | |
| 111 void* thread_handle = CreateThread( | 112 void* thread_handle = CreateThread( |
| 112 NULL, stack_size, ThreadFunc, params, flags, NULL); | 113 NULL, stack_size, ThreadFunc, params, flags, &thread_id); |
| 113 if (!thread_handle) { | 114 if (!thread_handle) { |
| 114 delete params; | 115 delete params; |
| 115 return false; | 116 return false; |
| 116 } | 117 } |
| 117 | 118 |
| 118 if (out_thread_handle) | 119 if (out_thread_handle) { |
|
rvargas (doing something else)
2015/03/26 02:19:27
nit: no need for {}
kinuko
2015/04/13 02:02:59
Done.
| |
| 119 *out_thread_handle = PlatformThreadHandle(thread_handle); | 120 *out_thread_handle = PlatformThreadHandle(thread_handle, thread_id); |
| 120 else | 121 } else { |
| 121 CloseHandle(thread_handle); | 122 CloseHandle(thread_handle); |
| 123 } | |
| 122 return true; | 124 return true; |
| 123 } | 125 } |
| 124 | 126 |
| 125 } // namespace | 127 } // namespace |
| 126 | 128 |
| 127 // static | 129 // static |
| 128 PlatformThreadId PlatformThread::CurrentId() { | 130 PlatformThreadId PlatformThread::CurrentId() { |
| 129 return GetCurrentThreadId(); | 131 return GetCurrentThreadId(); |
| 130 } | 132 } |
| 131 | 133 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 case kThreadPriority_RealtimeAudio: | 243 case kThreadPriority_RealtimeAudio: |
| 242 ::SetThreadPriority(handle.handle_, THREAD_PRIORITY_TIME_CRITICAL); | 244 ::SetThreadPriority(handle.handle_, THREAD_PRIORITY_TIME_CRITICAL); |
| 243 break; | 245 break; |
| 244 default: | 246 default: |
| 245 NOTREACHED() << "Unknown priority."; | 247 NOTREACHED() << "Unknown priority."; |
| 246 break; | 248 break; |
| 247 } | 249 } |
| 248 } | 250 } |
| 249 | 251 |
| 250 } // namespace base | 252 } // namespace base |
| OLD | NEW |