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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 bool joinable; | 48 bool joinable; |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 DWORD __stdcall ThreadFunc(void* params) { | 51 DWORD __stdcall ThreadFunc(void* params) { |
| 52 ThreadParams* thread_params = static_cast<ThreadParams*>(params); | 52 ThreadParams* thread_params = static_cast<ThreadParams*>(params); |
| 53 PlatformThread::Delegate* delegate = thread_params->delegate; | 53 PlatformThread::Delegate* delegate = thread_params->delegate; |
| 54 if (!thread_params->joinable) | 54 if (!thread_params->joinable) |
| 55 base::ThreadRestrictions::SetSingletonAllowed(false); | 55 base::ThreadRestrictions::SetSingletonAllowed(false); |
| 56 | 56 |
| 57 /* Retrieve a copy of the thread handle to use as the key in the | 57 /* Retrieve a copy of the thread handle to use as the key in the |
| 58 * thread name mapping. */ | 58 * thread name mapping. */ |
|
rvargas (doing something else)
2013/12/02 20:19:37
Use c++ style comments
dsinclair
2013/12/10 21:08:20
Done.
| |
| 59 PlatformThreadHandle::Handle platform_handle; | 59 PlatformThreadHandle::Handle platform_handle; |
| 60 DuplicateHandle( | 60 DuplicateHandle( |
|
jar (doing other things)
2013/11/28 19:01:22
Is it worth checking the return value for success?
rvargas (doing something else)
2013/12/02 20:19:37
Yes, check the return value!. Create a win::Scoped
dsinclair
2013/12/10 21:08:20
Done.
| |
| 61 GetCurrentProcess(), | 61 GetCurrentProcess(), |
| 62 GetCurrentThread(), | 62 GetCurrentThread(), |
| 63 GetCurrentProcess(), | 63 GetCurrentProcess(), |
| 64 &platform_handle, | 64 &platform_handle, |
| 65 0, | 65 0, |
| 66 FALSE, | 66 FALSE, |
| 67 DUPLICATE_SAME_ACCESS); | 67 DUPLICATE_SAME_ACCESS); |
| 68 | 68 |
| 69 ThreadIdNameManager::GetInstance()->RegisterThread( | 69 ThreadIdNameManager::GetInstance()->RegisterThread( |
| 70 platform_handle, | 70 platform_handle, |
| 71 PlatformThread::CurrentId()); | 71 PlatformThread::CurrentId()); |
| 72 | 72 |
| 73 delete thread_params; | 73 delete thread_params; |
| 74 delegate->ThreadMain(); | 74 delegate->ThreadMain(); |
| 75 | 75 |
| 76 ThreadIdNameManager::GetInstance()->RemoveName( | 76 ThreadIdNameManager::GetInstance()->RemoveName( |
| 77 platform_handle, | 77 platform_handle, |
| 78 PlatformThread::CurrentId()); | 78 PlatformThread::CurrentId()); |
| 79 | |
| 80 CloseHandle(platform_handle); | |
|
zhaoqin
2013/11/28 16:07:33
Actually I am not sure this is the correct solutio
dsinclair
2013/11/28 16:13:40
Right, but the line immediately above:
ThreadId
zhaoqin
2013/11/28 16:25:41
I see, my bad.
dsinclair
2013/11/28 16:31:07
I don't think so, ThreadIdNameManager doesn't know
| |
| 81 | |
| 79 return NULL; | 82 return NULL; |
| 80 } | 83 } |
| 81 | 84 |
| 82 // CreateThreadInternal() matches PlatformThread::Create(), except that | 85 // CreateThreadInternal() matches PlatformThread::Create(), except that |
| 83 // |out_thread_handle| may be NULL, in which case a non-joinable thread is | 86 // |out_thread_handle| may be NULL, in which case a non-joinable thread is |
| 84 // created. | 87 // created. |
| 85 bool CreateThreadInternal(size_t stack_size, | 88 bool CreateThreadInternal(size_t stack_size, |
| 86 PlatformThread::Delegate* delegate, | 89 PlatformThread::Delegate* delegate, |
| 87 PlatformThreadHandle* out_thread_handle) { | 90 PlatformThreadHandle* out_thread_handle) { |
| 88 unsigned int flags = 0; | 91 unsigned int flags = 0; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 case kThreadPriority_RealtimeAudio: | 233 case kThreadPriority_RealtimeAudio: |
| 231 ::SetThreadPriority(handle.handle_, THREAD_PRIORITY_TIME_CRITICAL); | 234 ::SetThreadPriority(handle.handle_, THREAD_PRIORITY_TIME_CRITICAL); |
| 232 break; | 235 break; |
| 233 default: | 236 default: |
| 234 NOTREACHED() << "Unknown priority."; | 237 NOTREACHED() << "Unknown priority."; |
| 235 break; | 238 break; |
| 236 } | 239 } |
| 237 } | 240 } |
| 238 | 241 |
| 239 } // namespace base | 242 } // namespace base |
| OLD | NEW |