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/activity_tracker.h" |
9 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
10 #include "base/debug/profiler.h" | 11 #include "base/debug/profiler.h" |
11 #include "base/logging.h" | 12 #include "base/logging.h" |
12 #include "base/threading/thread_id_name_manager.h" | 13 #include "base/threading/thread_id_name_manager.h" |
13 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
14 #include "base/tracked_objects.h" | 15 #include "base/tracked_objects.h" |
15 #include "base/win/scoped_handle.h" | 16 #include "base/win/scoped_handle.h" |
16 #include "base/win/windows_version.h" | 17 #include "base/win/windows_version.h" |
17 | 18 |
18 namespace base { | 19 namespace base { |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 } | 199 } |
199 | 200 |
200 // static | 201 // static |
201 bool PlatformThread::CreateNonJoinable(size_t stack_size, Delegate* delegate) { | 202 bool PlatformThread::CreateNonJoinable(size_t stack_size, Delegate* delegate) { |
202 return CreateThreadInternal(stack_size, delegate, nullptr, | 203 return CreateThreadInternal(stack_size, delegate, nullptr, |
203 ThreadPriority::NORMAL); | 204 ThreadPriority::NORMAL); |
204 } | 205 } |
205 | 206 |
206 // static | 207 // static |
207 void PlatformThread::Join(PlatformThreadHandle thread_handle) { | 208 void PlatformThread::Join(PlatformThreadHandle thread_handle) { |
| 209 // Record the event that this thread is blocking upon (for hang diagonsis). |
| 210 base::debug::ScopedThreadJoinActivity thread_activity(&thread_handle); |
| 211 |
208 DCHECK(thread_handle.platform_handle()); | 212 DCHECK(thread_handle.platform_handle()); |
209 // TODO(willchan): Enable this check once I can get it to work for Windows | 213 // TODO(willchan): Enable this check once I can get it to work for Windows |
210 // shutdown. | 214 // shutdown. |
211 // Joining another thread may block the current thread for a long time, since | 215 // 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 / | 216 // the thread referred to by |thread_handle| may still be running long-lived / |
213 // blocking tasks. | 217 // blocking tasks. |
214 #if 0 | 218 #if 0 |
215 base::ThreadRestrictions::AssertIOAllowed(); | 219 base::ThreadRestrictions::AssertIOAllowed(); |
216 #endif | 220 #endif |
217 | 221 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 return ThreadPriority::REALTIME_AUDIO; | 279 return ThreadPriority::REALTIME_AUDIO; |
276 case THREAD_PRIORITY_ERROR_RETURN: | 280 case THREAD_PRIORITY_ERROR_RETURN: |
277 DPCHECK(false) << "GetThreadPriority error"; // Falls through. | 281 DPCHECK(false) << "GetThreadPriority error"; // Falls through. |
278 default: | 282 default: |
279 NOTREACHED() << "Unexpected priority: " << priority; | 283 NOTREACHED() << "Unexpected priority: " << priority; |
280 return ThreadPriority::NORMAL; | 284 return ThreadPriority::NORMAL; |
281 } | 285 } |
282 } | 286 } |
283 | 287 |
284 } // namespace base | 288 } // namespace base |
OLD | NEW |