| 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/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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 PlatformThreadId PlatformThread::CurrentId() { | 102 PlatformThreadId PlatformThread::CurrentId() { |
| 103 return GetCurrentThreadId(); | 103 return GetCurrentThreadId(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 // static | 106 // static |
| 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) { | |
| 113 ::Sleep(duration_ms); | |
| 114 } | |
| 115 | |
| 116 // static | |
| 117 void PlatformThread::Sleep(TimeDelta duration) { | 112 void PlatformThread::Sleep(TimeDelta duration) { |
| 118 ::Sleep(duration.InMillisecondsRoundedUp()); | 113 ::Sleep(duration.InMillisecondsRoundedUp()); |
| 119 } | 114 } |
| 120 | 115 |
| 121 // static | 116 // static |
| 122 void PlatformThread::SetName(const char* name) { | 117 void PlatformThread::SetName(const char* name) { |
| 123 current_thread_name.Set(const_cast<char*>(name)); | 118 current_thread_name.Set(const_cast<char*>(name)); |
| 124 | 119 |
| 125 // On Windows only, we don't need to tell the profiler about the "BrokerEvent" | 120 // On Windows only, we don't need to tell the profiler about the "BrokerEvent" |
| 126 // thread, as it exists only in the chrome.exe image, and never spawns or runs | 121 // thread, as it exists only in the chrome.exe image, and never spawns or runs |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 case kThreadPriority_Normal: | 195 case kThreadPriority_Normal: |
| 201 ::SetThreadPriority(handle, THREAD_PRIORITY_NORMAL); | 196 ::SetThreadPriority(handle, THREAD_PRIORITY_NORMAL); |
| 202 break; | 197 break; |
| 203 case kThreadPriority_RealtimeAudio: | 198 case kThreadPriority_RealtimeAudio: |
| 204 ::SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL); | 199 ::SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL); |
| 205 break; | 200 break; |
| 206 } | 201 } |
| 207 } | 202 } |
| 208 | 203 |
| 209 } // namespace base | 204 } // namespace base |
| OLD | NEW |