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 <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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 } // namespace | 153 } // namespace |
154 | 154 |
155 // static | 155 // static |
156 PlatformThreadId PlatformThread::CurrentId() { | 156 PlatformThreadId PlatformThread::CurrentId() { |
157 // Pthreads doesn't have the concept of a thread ID, so we have to reach down | 157 // Pthreads doesn't have the concept of a thread ID, so we have to reach down |
158 // into the kernel. | 158 // into the kernel. |
159 #if defined(OS_LINUX) | 159 #if defined(OS_LINUX) |
160 return syscall(__NR_gettid); | 160 return syscall(__NR_gettid); |
161 #elif defined(OS_ANDROID) | 161 #elif defined(OS_ANDROID) |
162 return gettid(); | 162 return gettid(); |
163 #elif defined(OS_NACL) || defined(OS_SOLARIS) | 163 #elif defined(OS_SOLARIS) |
164 return pthread_self(); | 164 return pthread_self(); |
165 #elif defined(OS_POSIX) | 165 #elif defined(OS_NACL) || (OS_POSIX) |
166 return reinterpret_cast<int64>(pthread_self()); | 166 return reinterpret_cast<int64>(pthread_self()); |
bbudge
2012/05/22 01:58:14
Maybe it would be better to cast to int32 since pt
| |
167 #endif | 167 #endif |
168 } | 168 } |
169 | 169 |
170 // static | 170 // static |
171 void PlatformThread::YieldCurrentThread() { | 171 void PlatformThread::YieldCurrentThread() { |
172 sched_yield(); | 172 sched_yield(); |
173 } | 173 } |
174 | 174 |
175 // static | 175 // static |
176 void PlatformThread::Sleep(int duration_ms) { | 176 void PlatformThread::Sleep(int duration_ms) { |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 #if !defined(OS_MACOSX) | 279 #if !defined(OS_MACOSX) |
280 // Mac OS X uses lower-level mach APIs. | 280 // Mac OS X uses lower-level mach APIs. |
281 | 281 |
282 // static | 282 // static |
283 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { | 283 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { |
284 // TODO(crogers): Implement, see http://crbug.com/116172 | 284 // TODO(crogers): Implement, see http://crbug.com/116172 |
285 } | 285 } |
286 #endif | 286 #endif |
287 | 287 |
288 } // namespace base | 288 } // namespace base |
OLD | NEW |