| 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 10 matching lines...) Expand all Loading... |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 static void* ThreadFunc(void* closure) { | 23 static void* ThreadFunc(void* closure) { |
| 24 PlatformThread::Delegate* delegate = | 24 PlatformThread::Delegate* delegate = |
| 25 static_cast<PlatformThread::Delegate*>(closure); | 25 static_cast<PlatformThread::Delegate*>(closure); |
| 26 delegate->ThreadMain(); | 26 delegate->ThreadMain(); |
| 27 return NULL; | 27 return NULL; |
| 28 } | 28 } |
| 29 | 29 |
| 30 // static | 30 // static |
| 31 int 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 #endif | 38 #endif |
| 39 } | 39 } |
| 40 | 40 |
| 41 // static | 41 // static |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 success = !pthread_create(thread_handle, &attributes, ThreadFunc, delegate); | 88 success = !pthread_create(thread_handle, &attributes, ThreadFunc, delegate); |
| 89 | 89 |
| 90 pthread_attr_destroy(&attributes); | 90 pthread_attr_destroy(&attributes); |
| 91 return success; | 91 return success; |
| 92 } | 92 } |
| 93 | 93 |
| 94 // static | 94 // static |
| 95 void PlatformThread::Join(PlatformThreadHandle thread_handle) { | 95 void PlatformThread::Join(PlatformThreadHandle thread_handle) { |
| 96 pthread_join(thread_handle, NULL); | 96 pthread_join(thread_handle, NULL); |
| 97 } | 97 } |
| OLD | NEW |