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 | |
118 void PlatformThread::Sleep(TimeDelta duration) { | 113 void PlatformThread::Sleep(TimeDelta duration) { |
119 ::Sleep(duration.InMillisecondsRoundedUp()); | 114 ::Sleep(duration.InMillisecondsRoundedUp()); |
120 } | 115 } |
121 | 116 |
122 // static | 117 // static |
123 void PlatformThread::SetName(const char* name) { | 118 void PlatformThread::SetName(const char* name) { |
124 current_thread_name.Set(const_cast<char*>(name)); | 119 current_thread_name.Set(const_cast<char*>(name)); |
125 | 120 |
126 // On Windows only, we don't need to tell the profiler about the "BrokerEvent" | 121 // On Windows only, we don't need to tell the profiler about the "BrokerEvent" |
127 // thread, as it exists only in the chrome.exe image, and never spawns or runs | 122 // 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... |
203 case kThreadPriority_Normal: | 198 case kThreadPriority_Normal: |
204 ::SetThreadPriority(handle, THREAD_PRIORITY_NORMAL); | 199 ::SetThreadPriority(handle, THREAD_PRIORITY_NORMAL); |
205 break; | 200 break; |
206 case kThreadPriority_RealtimeAudio: | 201 case kThreadPriority_RealtimeAudio: |
207 ::SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL); | 202 ::SetThreadPriority(handle, THREAD_PRIORITY_TIME_CRITICAL); |
208 break; | 203 break; |
209 } | 204 } |
210 } | 205 } |
211 | 206 |
212 } // namespace base | 207 } // namespace base |
OLD | NEW |