| 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 VM_OS_THREAD_H_ | 5 #ifndef VM_OS_THREAD_H_ |
| 6 #define VM_OS_THREAD_H_ | 6 #define VM_OS_THREAD_H_ |
| 7 | 7 |
| 8 #include "platform/globals.h" | 8 #include "platform/globals.h" |
| 9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #endif | 22 #endif |
| 23 | 23 |
| 24 namespace dart { | 24 namespace dart { |
| 25 | 25 |
| 26 // Low-level operations on OS platform threads. | 26 // Low-level operations on OS platform threads. |
| 27 // TODO(koda): Move to runtime/platform. | 27 // TODO(koda): Move to runtime/platform. |
| 28 class OSThread { | 28 class OSThread { |
| 29 public: | 29 public: |
| 30 static ThreadLocalKey kUnsetThreadLocalKey; | 30 static ThreadLocalKey kUnsetThreadLocalKey; |
| 31 static ThreadId kInvalidThreadId; | 31 static ThreadId kInvalidThreadId; |
| 32 static ThreadJoinId kInvalidThreadJoinId; |
| 32 | 33 |
| 33 typedef void (*ThreadStartFunction) (uword parameter); | 34 typedef void (*ThreadStartFunction) (uword parameter); |
| 34 typedef void (*ThreadDestructor) (void* parameter); | 35 typedef void (*ThreadDestructor) (void* parameter); |
| 35 | 36 |
| 36 // Start a thread running the specified function. Returns 0 if the | 37 // Start a thread running the specified function. Returns 0 if the |
| 37 // thread started successfuly and a system specific error code if | 38 // thread started successfuly and a system specific error code if |
| 38 // the thread failed to start. | 39 // the thread failed to start. |
| 39 static int Start(ThreadStartFunction function, uword parameters); | 40 static int Start(ThreadStartFunction function, uword parameters); |
| 40 | 41 |
| 41 // NOTE: Destructor currently ignored on Windows (issue 23474). | 42 // NOTE: Destructor currently ignored on Windows (issue 23474). |
| 42 static ThreadLocalKey CreateThreadLocal(ThreadDestructor destructor = NULL); | 43 static ThreadLocalKey CreateThreadLocal(ThreadDestructor destructor = NULL); |
| 43 static void DeleteThreadLocal(ThreadLocalKey key); | 44 static void DeleteThreadLocal(ThreadLocalKey key); |
| 44 static uword GetThreadLocal(ThreadLocalKey key) { | 45 static uword GetThreadLocal(ThreadLocalKey key) { |
| 45 return ThreadInlineImpl::GetThreadLocal(key); | 46 return ThreadInlineImpl::GetThreadLocal(key); |
| 46 } | 47 } |
| 47 static void SetThreadLocal(ThreadLocalKey key, uword value); | 48 static void SetThreadLocal(ThreadLocalKey key, uword value); |
| 48 static intptr_t GetMaxStackSize(); | 49 static intptr_t GetMaxStackSize(); |
| 49 static ThreadId GetCurrentThreadId(); | 50 static ThreadId GetCurrentThreadId(); |
| 50 static intptr_t CurrentCurrentThreadIdAsIntPtr() { | 51 static intptr_t CurrentCurrentThreadIdAsIntPtr() { |
| 51 return ThreadIdToIntPtr(GetCurrentThreadId()); | 52 return ThreadIdToIntPtr(GetCurrentThreadId()); |
| 52 } | 53 } |
| 53 static bool Join(ThreadId id); | 54 static ThreadJoinId GetCurrentThreadJoinId(); |
| 55 static void Join(ThreadJoinId id); |
| 54 static intptr_t ThreadIdToIntPtr(ThreadId id); | 56 static intptr_t ThreadIdToIntPtr(ThreadId id); |
| 55 static ThreadId ThreadIdFromIntPtr(intptr_t id); | 57 static ThreadId ThreadIdFromIntPtr(intptr_t id); |
| 56 static bool Compare(ThreadId a, ThreadId b); | 58 static bool Compare(ThreadId a, ThreadId b); |
| 57 static void GetThreadCpuUsage(ThreadId thread_id, int64_t* cpu_usage); | 59 static void GetThreadCpuUsage(ThreadId thread_id, int64_t* cpu_usage); |
| 58 }; | 60 }; |
| 59 | 61 |
| 60 | 62 |
| 61 class Mutex { | 63 class Mutex { |
| 62 public: | 64 public: |
| 63 Mutex(); | 65 Mutex(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 MonitorData data_; // OS-specific data. | 112 MonitorData data_; // OS-specific data. |
| 111 | 113 |
| 112 DISALLOW_COPY_AND_ASSIGN(Monitor); | 114 DISALLOW_COPY_AND_ASSIGN(Monitor); |
| 113 }; | 115 }; |
| 114 | 116 |
| 115 | 117 |
| 116 } // namespace dart | 118 } // namespace dart |
| 117 | 119 |
| 118 | 120 |
| 119 #endif // VM_OS_THREAD_H_ | 121 #endif // VM_OS_THREAD_H_ |
| OLD | NEW |