| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/threading/thread_local.h" | 9 #include "base/threading/thread_local.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 void PlatformThread::YieldCurrentThread() { | 107 void PlatformThread::YieldCurrentThread() { |
| 108 ::Sleep(0); | 108 ::Sleep(0); |
| 109 } | 109 } |
| 110 | 110 |
| 111 // static | 111 // static |
| 112 void PlatformThread::Sleep(int duration_ms) { | 112 void PlatformThread::Sleep(int duration_ms) { |
| 113 ::Sleep(duration_ms); | 113 ::Sleep(duration_ms); |
| 114 } | 114 } |
| 115 | 115 |
| 116 // static | 116 // static |
| 117 void PlatformThread::Sleep(TimeDelta duration) { |
| 118 ::Sleep(duration.InMillisecondsRoundedUp()); |
| 119 } |
| 120 |
| 121 // static |
| 117 void PlatformThread::SetName(const char* name) { | 122 void PlatformThread::SetName(const char* name) { |
| 118 current_thread_name.Set(const_cast<char*>(name)); | 123 current_thread_name.Set(const_cast<char*>(name)); |
| 119 tracked_objects::ThreadData::InitializeThreadContext(name); | 124 tracked_objects::ThreadData::InitializeThreadContext(name); |
| 120 | 125 |
| 121 // The debugger needs to be around to catch the name in the exception. If | 126 // The debugger needs to be around to catch the name in the exception. If |
| 122 // there isn't a debugger, we are just needlessly throwing an exception. | 127 // there isn't a debugger, we are just needlessly throwing an exception. |
| 123 if (!::IsDebuggerPresent()) | 128 if (!::IsDebuggerPresent()) |
| 124 return; | 129 return; |
| 125 | 130 |
| 126 SetNameInternal(CurrentId(), name); | 131 SetNameInternal(CurrentId(), name); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 case kThreadPriority_RealtimeAudio: | 178 case kThreadPriority_RealtimeAudio: |
| 174 ::SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL); | 179 ::SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL); |
| 175 break; | 180 break; |
| 176 default: | 181 default: |
| 177 NOTIMPLEMENTED(); | 182 NOTIMPLEMENTED(); |
| 178 break; | 183 break; |
| 179 } | 184 } |
| 180 } | 185 } |
| 181 | 186 |
| 182 } // namespace base | 187 } // namespace base |
| OLD | NEW |