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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/debug/alias.h" | 9 #include "base/debug/alias.h" |
| 10 #include "base/debug/profiler.h" | 10 #include "base/debug/profiler.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 // the thread referred to by |thread_handle| may still be running long-lived / | 212 // the thread referred to by |thread_handle| may still be running long-lived / |
| 213 // blocking tasks. | 213 // blocking tasks. |
| 214 #if 0 | 214 #if 0 |
| 215 base::ThreadRestrictions::AssertIOAllowed(); | 215 base::ThreadRestrictions::AssertIOAllowed(); |
| 216 #endif | 216 #endif |
| 217 | 217 |
| 218 // Wait for the thread to exit. It should already have terminated but make | 218 // Wait for the thread to exit. It should already have terminated but make |
| 219 // sure this assumption is valid. | 219 // sure this assumption is valid. |
| 220 DWORD result = WaitForSingleObject(thread_handle.platform_handle(), INFINITE); | 220 DWORD result = WaitForSingleObject(thread_handle.platform_handle(), INFINITE); |
| 221 if (result != WAIT_OBJECT_0) { | 221 if (result != WAIT_OBJECT_0) { |
| 222 // Debug info for bug 127931. | 222 // Debug info for bug 127931. |
|
danakj
2016/06/09 22:58:07
Oh fun, this bug is fixed, maybe you can clean thi
robliao
2016/06/10 14:24:31
Clean up done at https://codereview.chromium.org/2
| |
| 223 DWORD error = GetLastError(); | 223 DWORD error = GetLastError(); |
| 224 debug::Alias(&error); | 224 debug::Alias(&error); |
| 225 debug::Alias(&result); | 225 debug::Alias(&result); |
| 226 CHECK(false); | 226 CHECK(false); |
| 227 } | 227 } |
| 228 | 228 |
| 229 CloseHandle(thread_handle.platform_handle()); | 229 CloseHandle(thread_handle.platform_handle()); |
| 230 } | 230 } |
| 231 | 231 |
| 232 // static | 232 // static |
| 233 void PlatformThread::Detach(PlatformThreadHandle thread_handle) { | |
| 234 CloseHandle(thread_handle.platform_handle()); | |
| 235 } | |
| 236 | |
| 237 // static | |
| 233 void PlatformThread::SetCurrentThreadPriority(ThreadPriority priority) { | 238 void PlatformThread::SetCurrentThreadPriority(ThreadPriority priority) { |
| 234 int desired_priority = THREAD_PRIORITY_ERROR_RETURN; | 239 int desired_priority = THREAD_PRIORITY_ERROR_RETURN; |
| 235 switch (priority) { | 240 switch (priority) { |
| 236 case ThreadPriority::BACKGROUND: | 241 case ThreadPriority::BACKGROUND: |
| 237 desired_priority = THREAD_PRIORITY_LOWEST; | 242 desired_priority = THREAD_PRIORITY_LOWEST; |
| 238 break; | 243 break; |
| 239 case ThreadPriority::NORMAL: | 244 case ThreadPriority::NORMAL: |
| 240 desired_priority = THREAD_PRIORITY_NORMAL; | 245 desired_priority = THREAD_PRIORITY_NORMAL; |
| 241 break; | 246 break; |
| 242 case ThreadPriority::DISPLAY: | 247 case ThreadPriority::DISPLAY: |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 return ThreadPriority::REALTIME_AUDIO; | 280 return ThreadPriority::REALTIME_AUDIO; |
| 276 case THREAD_PRIORITY_ERROR_RETURN: | 281 case THREAD_PRIORITY_ERROR_RETURN: |
| 277 DPCHECK(false) << "GetThreadPriority error"; // Falls through. | 282 DPCHECK(false) << "GetThreadPriority error"; // Falls through. |
| 278 default: | 283 default: |
| 279 NOTREACHED() << "Unexpected priority: " << priority; | 284 NOTREACHED() << "Unexpected priority: " << priority; |
| 280 return ThreadPriority::NORMAL; | 285 return ThreadPriority::NORMAL; |
| 281 } | 286 } |
| 282 } | 287 } |
| 283 | 288 |
| 284 } // namespace base | 289 } // namespace base |
| OLD | NEW |