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