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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 ThreadParams* params = new ThreadParams; | 107 ThreadParams* params = new ThreadParams; |
| 108 params->delegate = delegate; | 108 params->delegate = delegate; |
| 109 params->joinable = out_thread_handle != NULL; | 109 params->joinable = out_thread_handle != NULL; |
| 110 params->priority = priority; | 110 params->priority = priority; |
| 111 | 111 |
| 112 // Using CreateThread here vs _beginthreadex makes thread creation a bit | 112 // Using CreateThread here vs _beginthreadex makes thread creation a bit |
| 113 // faster and doesn't require the loader lock to be available. Our code will | 113 // faster and doesn't require the loader lock to be available. Our code will |
| 114 // have to work running on CreateThread() threads anyway, since we run code | 114 // have to work running on CreateThread() threads anyway, since we run code |
| 115 // on the Windows thread pool, etc. For some background on the difference: | 115 // on the Windows thread pool, etc. For some background on the difference: |
| 116 // http://www.microsoft.com/msj/1099/win32/win321099.aspx | 116 // http://www.microsoft.com/msj/1099/win32/win321099.aspx |
| 117 PlatformThreadId thread_id; | 117 PlatformThreadId thread_id; |
|
Lei Zhang
2015/07/20 21:27:32
No longer used on line 126, so pass a nullptr to :
Takashi Toyoshima
2015/07/21 16:05:37
Done.
| |
| 118 void* thread_handle = CreateThread( | 118 void* thread_handle = CreateThread( |
| 119 NULL, stack_size, ThreadFunc, params, flags, &thread_id); | 119 NULL, stack_size, ThreadFunc, params, flags, &thread_id); |
| 120 if (!thread_handle) { | 120 if (!thread_handle) { |
| 121 delete params; | 121 delete params; |
| 122 return false; | 122 return false; |
| 123 } | 123 } |
| 124 | 124 |
| 125 if (out_thread_handle) | 125 if (out_thread_handle) |
| 126 *out_thread_handle = PlatformThreadHandle(thread_handle, thread_id); | 126 *out_thread_handle = PlatformThreadHandle(thread_handle); |
| 127 else | 127 else |
| 128 CloseHandle(thread_handle); | 128 CloseHandle(thread_handle); |
| 129 return true; | 129 return true; |
| 130 } | 130 } |
| 131 | 131 |
| 132 } // namespace | 132 } // namespace |
| 133 | 133 |
| 134 // static | 134 // static |
| 135 PlatformThreadId PlatformThread::CurrentId() { | 135 PlatformThreadId PlatformThread::CurrentId() { |
| 136 return ::GetCurrentThreadId(); | 136 return ::GetCurrentThreadId(); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 return ThreadPriority::REALTIME_AUDIO; | 281 return ThreadPriority::REALTIME_AUDIO; |
| 282 case THREAD_PRIORITY_ERROR_RETURN: | 282 case THREAD_PRIORITY_ERROR_RETURN: |
| 283 DPCHECK(false) << "GetThreadPriority error"; // Falls through. | 283 DPCHECK(false) << "GetThreadPriority error"; // Falls through. |
| 284 default: | 284 default: |
| 285 NOTREACHED() << "Unexpected priority: " << priority; | 285 NOTREACHED() << "Unexpected priority: " << priority; |
| 286 return ThreadPriority::NORMAL; | 286 return ThreadPriority::NORMAL; |
| 287 } | 287 } |
| 288 } | 288 } |
| 289 | 289 |
| 290 } // namespace base | 290 } // namespace base |
| OLD | NEW |