| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef RUNTIME_VM_OS_THREAD_ANDROID_H_ | 5 #ifndef RUNTIME_VM_OS_THREAD_ANDROID_H_ |
| 6 #define RUNTIME_VM_OS_THREAD_ANDROID_H_ | 6 #define RUNTIME_VM_OS_THREAD_ANDROID_H_ |
| 7 | 7 |
| 8 #if !defined(RUNTIME_VM_OS_THREAD_H_) | 8 #if !defined(RUNTIME_VM_OS_THREAD_H_) |
| 9 #error Do not include os_thread_android.h directly; use os_thread.h instead. | 9 #error Do not include os_thread_android.h directly; use os_thread.h instead. |
| 10 #endif | 10 #endif |
| 11 | 11 |
| 12 #include <pthread.h> | 12 #include <pthread.h> |
| 13 | 13 |
| 14 #include "platform/assert.h" | 14 #include "platform/assert.h" |
| 15 #include "platform/globals.h" | 15 #include "platform/globals.h" |
| 16 | 16 |
| 17 namespace dart { | 17 namespace dart { |
| 18 | 18 |
| 19 typedef pthread_key_t ThreadLocalKey; | 19 typedef pthread_key_t ThreadLocalKey; |
| 20 typedef pid_t ThreadId; | 20 typedef pid_t ThreadId; |
| 21 typedef pthread_t ThreadJoinId; | 21 typedef pthread_t ThreadJoinId; |
| 22 | 22 |
| 23 | |
| 24 static const ThreadLocalKey kUnsetThreadLocalKey = | 23 static const ThreadLocalKey kUnsetThreadLocalKey = |
| 25 static_cast<pthread_key_t>(-1); | 24 static_cast<pthread_key_t>(-1); |
| 26 | 25 |
| 27 | |
| 28 class ThreadInlineImpl { | 26 class ThreadInlineImpl { |
| 29 private: | 27 private: |
| 30 ThreadInlineImpl() {} | 28 ThreadInlineImpl() {} |
| 31 ~ThreadInlineImpl() {} | 29 ~ThreadInlineImpl() {} |
| 32 | 30 |
| 33 static uword GetThreadLocal(ThreadLocalKey key) { | 31 static uword GetThreadLocal(ThreadLocalKey key) { |
| 34 ASSERT(key != kUnsetThreadLocalKey); | 32 ASSERT(key != kUnsetThreadLocalKey); |
| 35 return reinterpret_cast<uword>(pthread_getspecific(key)); | 33 return reinterpret_cast<uword>(pthread_getspecific(key)); |
| 36 } | 34 } |
| 37 | 35 |
| 38 friend class OSThread; | 36 friend class OSThread; |
| 39 | 37 |
| 40 DISALLOW_ALLOCATION(); | 38 DISALLOW_ALLOCATION(); |
| 41 DISALLOW_COPY_AND_ASSIGN(ThreadInlineImpl); | 39 DISALLOW_COPY_AND_ASSIGN(ThreadInlineImpl); |
| 42 }; | 40 }; |
| 43 | 41 |
| 44 | |
| 45 class MutexData { | 42 class MutexData { |
| 46 private: | 43 private: |
| 47 MutexData() {} | 44 MutexData() {} |
| 48 ~MutexData() {} | 45 ~MutexData() {} |
| 49 | 46 |
| 50 pthread_mutex_t* mutex() { return &mutex_; } | 47 pthread_mutex_t* mutex() { return &mutex_; } |
| 51 | 48 |
| 52 pthread_mutex_t mutex_; | 49 pthread_mutex_t mutex_; |
| 53 | 50 |
| 54 friend class Mutex; | 51 friend class Mutex; |
| 55 | 52 |
| 56 DISALLOW_ALLOCATION(); | 53 DISALLOW_ALLOCATION(); |
| 57 DISALLOW_COPY_AND_ASSIGN(MutexData); | 54 DISALLOW_COPY_AND_ASSIGN(MutexData); |
| 58 }; | 55 }; |
| 59 | 56 |
| 60 | |
| 61 class MonitorData { | 57 class MonitorData { |
| 62 private: | 58 private: |
| 63 MonitorData() {} | 59 MonitorData() {} |
| 64 ~MonitorData() {} | 60 ~MonitorData() {} |
| 65 | 61 |
| 66 pthread_mutex_t* mutex() { return &mutex_; } | 62 pthread_mutex_t* mutex() { return &mutex_; } |
| 67 pthread_cond_t* cond() { return &cond_; } | 63 pthread_cond_t* cond() { return &cond_; } |
| 68 | 64 |
| 69 pthread_mutex_t mutex_; | 65 pthread_mutex_t mutex_; |
| 70 pthread_cond_t cond_; | 66 pthread_cond_t cond_; |
| 71 | 67 |
| 72 friend class Monitor; | 68 friend class Monitor; |
| 73 | 69 |
| 74 DISALLOW_ALLOCATION(); | 70 DISALLOW_ALLOCATION(); |
| 75 DISALLOW_COPY_AND_ASSIGN(MonitorData); | 71 DISALLOW_COPY_AND_ASSIGN(MonitorData); |
| 76 }; | 72 }; |
| 77 | 73 |
| 78 } // namespace dart | 74 } // namespace dart |
| 79 | 75 |
| 80 #endif // RUNTIME_VM_OS_THREAD_ANDROID_H_ | 76 #endif // RUNTIME_VM_OS_THREAD_ANDROID_H_ |
| OLD | NEW |