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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 /* Close the duplicated handle created for the thread name mapping. */ | |
81 DuplicateHandle( | |
82 GetCurrentProcess(), | |
83 platform_handle, | |
84 GetCurrentProcess(), | |
85 NULL, | |
zhaoqin
2013/11/26 20:35:56
This NULL will cause a handle leak.
It seems that
dsinclair
2013/11/28 15:51:14
Done.
| |
86 0, | |
87 FALSE, | |
88 DUPLICATE_CLOSE_SOURCE); | |
89 | |
90 CloseHandle(platform_handle); | |
zhaoqin
2013/11/26 20:35:56
If you use DUPLICATE_CLOSE_SOURCE above in Duplica
dsinclair
2013/11/28 15:51:14
Done.
| |
91 | |
79 return NULL; | 92 return NULL; |
80 } | 93 } |
81 | 94 |
82 // CreateThreadInternal() matches PlatformThread::Create(), except that | 95 // CreateThreadInternal() matches PlatformThread::Create(), except that |
83 // |out_thread_handle| may be NULL, in which case a non-joinable thread is | 96 // |out_thread_handle| may be NULL, in which case a non-joinable thread is |
84 // created. | 97 // created. |
85 bool CreateThreadInternal(size_t stack_size, | 98 bool CreateThreadInternal(size_t stack_size, |
86 PlatformThread::Delegate* delegate, | 99 PlatformThread::Delegate* delegate, |
87 PlatformThreadHandle* out_thread_handle) { | 100 PlatformThreadHandle* out_thread_handle) { |
88 unsigned int flags = 0; | 101 unsigned int flags = 0; |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
230 case kThreadPriority_RealtimeAudio: | 243 case kThreadPriority_RealtimeAudio: |
231 ::SetThreadPriority(handle.handle_, THREAD_PRIORITY_TIME_CRITICAL); | 244 ::SetThreadPriority(handle.handle_, THREAD_PRIORITY_TIME_CRITICAL); |
232 break; | 245 break; |
233 default: | 246 default: |
234 NOTREACHED() << "Unknown priority."; | 247 NOTREACHED() << "Unknown priority."; |
235 break; | 248 break; |
236 } | 249 } |
237 } | 250 } |
238 | 251 |
239 } // namespace base | 252 } // namespace base |
OLD | NEW |