Chromium Code Reviews| 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 | 142 |
| 143 } // namespace | 143 } // namespace |
| 144 | 144 |
| 145 // static | 145 // static |
| 146 PlatformThreadId PlatformThread::CurrentId() { | 146 PlatformThreadId PlatformThread::CurrentId() { |
| 147 // Pthreads doesn't have the concept of a thread ID, so we have to reach down | 147 // Pthreads doesn't have the concept of a thread ID, so we have to reach down |
| 148 // into the kernel. | 148 // into the kernel. |
| 149 #if defined(OS_MACOSX) | 149 #if defined(OS_MACOSX) |
| 150 return pthread_mach_thread_np(pthread_self()); | 150 return pthread_mach_thread_np(pthread_self()); |
| 151 #elif defined(OS_LINUX) | 151 #elif defined(OS_LINUX) |
| 152 return syscall(__NR_gettid); | 152 return pthread_self(); |
|
piman
2014/05/20 05:09:22
On my system, PlatformThreadId (a pid_t currently)
| |
| 153 #elif defined(OS_ANDROID) | 153 #elif defined(OS_ANDROID) |
| 154 return gettid(); | 154 return gettid(); |
| 155 #elif defined(OS_SOLARIS) || defined(OS_QNX) | 155 #elif defined(OS_SOLARIS) || defined(OS_QNX) |
| 156 return pthread_self(); | 156 return pthread_self(); |
| 157 #elif defined(OS_NACL) && defined(__GLIBC__) | 157 #elif defined(OS_NACL) && defined(__GLIBC__) |
| 158 return pthread_self(); | 158 return pthread_self(); |
| 159 #elif defined(OS_NACL) && !defined(__GLIBC__) | 159 #elif defined(OS_NACL) && !defined(__GLIBC__) |
| 160 // Pointers are 32-bits in NaCl. | 160 // Pointers are 32-bits in NaCl. |
| 161 return reinterpret_cast<int32>(pthread_self()); | 161 return reinterpret_cast<int32>(pthread_self()); |
| 162 #elif defined(OS_POSIX) | 162 #elif defined(OS_POSIX) |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 // static | 224 // static |
| 225 void PlatformThread::Join(PlatformThreadHandle thread_handle) { | 225 void PlatformThread::Join(PlatformThreadHandle thread_handle) { |
| 226 // Joining another thread may block the current thread for a long time, since | 226 // Joining another thread may block the current thread for a long time, since |
| 227 // the thread referred to by |thread_handle| may still be running long-lived / | 227 // the thread referred to by |thread_handle| may still be running long-lived / |
| 228 // blocking tasks. | 228 // blocking tasks. |
| 229 base::ThreadRestrictions::AssertIOAllowed(); | 229 base::ThreadRestrictions::AssertIOAllowed(); |
| 230 CHECK_EQ(0, pthread_join(thread_handle.handle_, NULL)); | 230 CHECK_EQ(0, pthread_join(thread_handle.handle_, NULL)); |
| 231 } | 231 } |
| 232 | 232 |
| 233 } // namespace base | 233 } // namespace base |
| OLD | NEW |