| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/platform_thread.h" | 5 #include "base/platform_thread.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <sched.h> | 8 #include <sched.h> |
| 9 | 9 |
| 10 #if defined(OS_MACOSX) | 10 #if defined(OS_MACOSX) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 } | 28 } |
| 29 | 29 |
| 30 // static | 30 // static |
| 31 PlatformThreadId PlatformThread::CurrentId() { | 31 PlatformThreadId PlatformThread::CurrentId() { |
| 32 // Pthreads doesn't have the concept of a thread ID, so we have to reach down | 32 // Pthreads doesn't have the concept of a thread ID, so we have to reach down |
| 33 // into the kernel. | 33 // into the kernel. |
| 34 #if defined(OS_MACOSX) | 34 #if defined(OS_MACOSX) |
| 35 return mach_thread_self(); | 35 return mach_thread_self(); |
| 36 #elif defined(OS_LINUX) | 36 #elif defined(OS_LINUX) |
| 37 return syscall(__NR_gettid); | 37 return syscall(__NR_gettid); |
| 38 #elif defined(OS_OPENBSD) |
| 39 return (PlatformThreadId)pthread_self(); |
| 38 #endif | 40 #endif |
| 39 } | 41 } |
| 40 | 42 |
| 41 // static | 43 // static |
| 42 void PlatformThread::YieldCurrentThread() { | 44 void PlatformThread::YieldCurrentThread() { |
| 43 sched_yield(); | 45 sched_yield(); |
| 44 } | 46 } |
| 45 | 47 |
| 46 // static | 48 // static |
| 47 void PlatformThread::Sleep(int duration_ms) { | 49 void PlatformThread::Sleep(int duration_ms) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 | 113 |
| 112 bool result = CreateThread(stack_size, false /* non-joinable thread */, | 114 bool result = CreateThread(stack_size, false /* non-joinable thread */, |
| 113 delegate, &unused); | 115 delegate, &unused); |
| 114 return result; | 116 return result; |
| 115 } | 117 } |
| 116 | 118 |
| 117 // static | 119 // static |
| 118 void PlatformThread::Join(PlatformThreadHandle thread_handle) { | 120 void PlatformThread::Join(PlatformThreadHandle thread_handle) { |
| 119 pthread_join(thread_handle, NULL); | 121 pthread_join(thread_handle, NULL); |
| 120 } | 122 } |
| OLD | NEW |