| 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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 // static | 204 // static |
| 204 bool PlatformThread::CreateNonJoinableWithPriority(size_t stack_size, | 205 bool PlatformThread::CreateNonJoinableWithPriority(size_t stack_size, |
| 205 Delegate* delegate, | 206 Delegate* delegate, |
| 206 ThreadPriority priority) { | 207 ThreadPriority priority) { |
| 207 return CreateThreadInternal(stack_size, delegate, nullptr /* non-joinable */, | 208 return CreateThreadInternal(stack_size, delegate, nullptr /* non-joinable */, |
| 208 priority); | 209 priority); |
| 209 } | 210 } |
| 210 | 211 |
| 211 // static | 212 // static |
| 212 void PlatformThread::Join(PlatformThreadHandle thread_handle) { | 213 void PlatformThread::Join(PlatformThreadHandle thread_handle) { |
| 214 // Record the event that this thread is blocking upon (for hang diagnosis). |
| 215 base::debug::ScopedThreadJoinActivity thread_activity(&thread_handle); |
| 216 |
| 213 DCHECK(thread_handle.platform_handle()); | 217 DCHECK(thread_handle.platform_handle()); |
| 214 // TODO(willchan): Enable this check once I can get it to work for Windows | 218 // TODO(willchan): Enable this check once I can get it to work for Windows |
| 215 // shutdown. | 219 // shutdown. |
| 216 // Joining another thread may block the current thread for a long time, since | 220 // Joining another thread may block the current thread for a long time, since |
| 217 // the thread referred to by |thread_handle| may still be running long-lived / | 221 // the thread referred to by |thread_handle| may still be running long-lived / |
| 218 // blocking tasks. | 222 // blocking tasks. |
| 219 #if 0 | 223 #if 0 |
| 220 base::ThreadRestrictions::AssertIOAllowed(); | 224 base::ThreadRestrictions::AssertIOAllowed(); |
| 221 #endif | 225 #endif |
| 222 | 226 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 return ThreadPriority::REALTIME_AUDIO; | 287 return ThreadPriority::REALTIME_AUDIO; |
| 284 case THREAD_PRIORITY_ERROR_RETURN: | 288 case THREAD_PRIORITY_ERROR_RETURN: |
| 285 DPCHECK(false) << "GetThreadPriority error"; // Falls through. | 289 DPCHECK(false) << "GetThreadPriority error"; // Falls through. |
| 286 default: | 290 default: |
| 287 NOTREACHED() << "Unexpected priority: " << priority; | 291 NOTREACHED() << "Unexpected priority: " << priority; |
| 288 return ThreadPriority::NORMAL; | 292 return ThreadPriority::NORMAL; |
| 289 } | 293 } |
| 290 } | 294 } |
| 291 | 295 |
| 292 } // namespace base | 296 } // namespace base |
| OLD | NEW |