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 | 17 |
17 namespace base { | 18 namespace base { |
18 | 19 |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 } | 196 } |
196 | 197 |
197 // static | 198 // static |
198 bool PlatformThread::CreateNonJoinable(size_t stack_size, Delegate* delegate) { | 199 bool PlatformThread::CreateNonJoinable(size_t stack_size, Delegate* delegate) { |
199 return CreateThreadInternal(stack_size, delegate, nullptr, | 200 return CreateThreadInternal(stack_size, delegate, nullptr, |
200 ThreadPriority::NORMAL); | 201 ThreadPriority::NORMAL); |
201 } | 202 } |
202 | 203 |
203 // static | 204 // static |
204 void PlatformThread::Join(PlatformThreadHandle thread_handle) { | 205 void PlatformThread::Join(PlatformThreadHandle thread_handle) { |
| 206 // Record the event that this thread is blocking upon (for hang diagnosis). |
| 207 base::debug::ScopedThreadJoinActivity thread_activity(&thread_handle); |
| 208 |
205 DCHECK(thread_handle.platform_handle()); | 209 DCHECK(thread_handle.platform_handle()); |
206 // TODO(willchan): Enable this check once I can get it to work for Windows | 210 // TODO(willchan): Enable this check once I can get it to work for Windows |
207 // shutdown. | 211 // shutdown. |
208 // Joining another thread may block the current thread for a long time, since | 212 // Joining another thread may block the current thread for a long time, since |
209 // the thread referred to by |thread_handle| may still be running long-lived / | 213 // the thread referred to by |thread_handle| may still be running long-lived / |
210 // blocking tasks. | 214 // blocking tasks. |
211 #if 0 | 215 #if 0 |
212 base::ThreadRestrictions::AssertIOAllowed(); | 216 base::ThreadRestrictions::AssertIOAllowed(); |
213 #endif | 217 #endif |
214 | 218 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 return ThreadPriority::REALTIME_AUDIO; | 274 return ThreadPriority::REALTIME_AUDIO; |
271 case THREAD_PRIORITY_ERROR_RETURN: | 275 case THREAD_PRIORITY_ERROR_RETURN: |
272 DPCHECK(false) << "GetThreadPriority error"; // Falls through. | 276 DPCHECK(false) << "GetThreadPriority error"; // Falls through. |
273 default: | 277 default: |
274 NOTREACHED() << "Unexpected priority: " << priority; | 278 NOTREACHED() << "Unexpected priority: " << priority; |
275 return ThreadPriority::NORMAL; | 279 return ThreadPriority::NORMAL; |
276 } | 280 } |
277 } | 281 } |
278 | 282 |
279 } // namespace base | 283 } // namespace base |
OLD | NEW |