Chromium Code Reviews| 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 <errno.h> | 7 #include <errno.h> |
| 8 #include <sched.h> | 8 #include <sched.h> |
| 9 | 9 |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 sleep_time.tv_sec = duration_ms / 1000; | 158 sleep_time.tv_sec = duration_ms / 1000; |
| 159 duration_ms -= sleep_time.tv_sec * 1000; | 159 duration_ms -= sleep_time.tv_sec * 1000; |
| 160 | 160 |
| 161 // Contains the portion of duration_ms < 1 sec. | 161 // Contains the portion of duration_ms < 1 sec. |
| 162 sleep_time.tv_nsec = duration_ms * 1000 * 1000; // nanoseconds. | 162 sleep_time.tv_nsec = duration_ms * 1000 * 1000; // nanoseconds. |
| 163 | 163 |
| 164 while (nanosleep(&sleep_time, &remaining) == -1 && errno == EINTR) | 164 while (nanosleep(&sleep_time, &remaining) == -1 && errno == EINTR) |
| 165 sleep_time = remaining; | 165 sleep_time = remaining; |
| 166 } | 166 } |
| 167 | 167 |
| 168 // static | |
| 169 void PlatformThread::Sleep(TimeDelta duration) { | |
| 170 // NOTE: This function is intended to supplant the other version of Sleep | |
| 171 // in the future. See issue 108171 for more information. | |
| 172 Sleep(duration.InMillisecondsRoundedUp()); | |
|
brettw
2011/12/28 20:10:27
It seems like this is backwards. Sleep(ms) should
| |
| 173 } | |
| 174 | |
| 168 #if defined(OS_LINUX) | 175 #if defined(OS_LINUX) |
| 169 // static | 176 // static |
| 170 void PlatformThread::SetName(const char* name) { | 177 void PlatformThread::SetName(const char* name) { |
| 171 // have to cast away const because ThreadLocalPointer does not support const | 178 // have to cast away const because ThreadLocalPointer does not support const |
| 172 // void* | 179 // void* |
| 173 current_thread_name.Pointer()->Set(const_cast<char*>(name)); | 180 current_thread_name.Pointer()->Set(const_cast<char*>(name)); |
| 174 tracked_objects::ThreadData::InitializeThreadContext(name); | 181 tracked_objects::ThreadData::InitializeThreadContext(name); |
| 175 | 182 |
| 176 // On linux we can get the thread names to show up in the debugger by setting | 183 // On linux we can get the thread names to show up in the debugger by setting |
| 177 // the process name for the LWP. We don't want to do this for the main | 184 // the process name for the LWP. We don't want to do this for the main |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 242 // Mac OS X uses lower-level mach APIs | 249 // Mac OS X uses lower-level mach APIs |
| 243 | 250 |
| 244 // static | 251 // static |
| 245 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { | 252 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { |
| 246 // TODO(crogers): implement | 253 // TODO(crogers): implement |
| 247 NOTIMPLEMENTED(); | 254 NOTIMPLEMENTED(); |
| 248 } | 255 } |
| 249 #endif | 256 #endif |
| 250 | 257 |
| 251 } // namespace base | 258 } // namespace base |
| OLD | NEW |