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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 210 // shutdown. | 210 // shutdown. |
| 211 // Joining another thread may block the current thread for a long time, since | 211 // Joining another thread may block the current thread for a long time, since |
| 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 CHECK_EQ(WAIT_OBJECT_0, |
|
danakj
2016/06/10 17:38:25
Can you make it a DCHECK also?
danakj
2016/06/10 17:41:06
I see you made a comment about this is bad so we s
robliao
2016/06/10 18:06:42
We CHECK on the equivalent call in POSIX.
https://
danakj
2016/06/10 22:03:32
Oh, okay thanks for the pointer. LGTM
| |
| 221 if (result != WAIT_OBJECT_0) { | 221 WaitForSingleObject(thread_handle.platform_handle(), INFINITE)); |
| 222 // Debug info for bug 127931. | |
| 223 DWORD error = GetLastError(); | |
| 224 debug::Alias(&error); | |
| 225 debug::Alias(&result); | |
| 226 CHECK(false); | |
| 227 } | |
| 228 | |
| 229 CloseHandle(thread_handle.platform_handle()); | 222 CloseHandle(thread_handle.platform_handle()); |
| 230 } | 223 } |
| 231 | 224 |
| 232 // static | 225 // static |
| 233 void PlatformThread::Detach(PlatformThreadHandle thread_handle) { | 226 void PlatformThread::Detach(PlatformThreadHandle thread_handle) { |
| 234 CloseHandle(thread_handle.platform_handle()); | 227 CloseHandle(thread_handle.platform_handle()); |
| 235 } | 228 } |
| 236 | 229 |
| 237 // static | 230 // static |
| 238 void PlatformThread::SetCurrentThreadPriority(ThreadPriority priority) { | 231 void PlatformThread::SetCurrentThreadPriority(ThreadPriority priority) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 280 return ThreadPriority::REALTIME_AUDIO; | 273 return ThreadPriority::REALTIME_AUDIO; |
| 281 case THREAD_PRIORITY_ERROR_RETURN: | 274 case THREAD_PRIORITY_ERROR_RETURN: |
| 282 DPCHECK(false) << "GetThreadPriority error"; // Falls through. | 275 DPCHECK(false) << "GetThreadPriority error"; // Falls through. |
| 283 default: | 276 default: |
| 284 NOTREACHED() << "Unexpected priority: " << priority; | 277 NOTREACHED() << "Unexpected priority: " << priority; |
| 285 return ThreadPriority::NORMAL; | 278 return ThreadPriority::NORMAL; |
| 286 } | 279 } |
| 287 } | 280 } |
| 288 | 281 |
| 289 } // namespace base | 282 } // namespace base |
| OLD | NEW |