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_THREAD_H_ | 5 #ifndef VM_THREAD_H_ |
6 #define VM_THREAD_H_ | 6 #define VM_THREAD_H_ |
7 | 7 |
8 #include "platform/globals.h" | 8 #include "platform/globals.h" |
9 | 9 |
10 // Declare the OS-specific types ahead of defining the generic classes. | 10 // Declare the OS-specific types ahead of defining the generic classes. |
11 #if defined(TARGET_OS_ANDROID) | 11 #if defined(TARGET_OS_ANDROID) |
12 #include "vm/thread_android.h" | 12 #include "vm/thread_android.h" |
13 #elif defined(TARGET_OS_LINUX) | 13 #elif defined(TARGET_OS_LINUX) |
14 #include "vm/thread_linux.h" | 14 #include "vm/thread_linux.h" |
15 #elif defined(TARGET_OS_MACOS) | 15 #elif defined(TARGET_OS_MACOS) |
16 #include "vm/thread_macos.h" | 16 #include "vm/thread_macos.h" |
17 #elif defined(TARGET_OS_WINDOWS) | 17 #elif defined(TARGET_OS_WINDOWS) |
18 #include "vm/thread_win.h" | 18 #include "vm/thread_win.h" |
19 #else | 19 #else |
20 #error Unknown target os. | 20 #error Unknown target os. |
21 #endif | 21 #endif |
22 | 22 |
23 namespace dart { | 23 namespace dart { |
24 | 24 |
| 25 class Isolate; |
| 26 |
25 class Thread { | 27 class Thread { |
26 public: | 28 public: |
27 static ThreadLocalKey kUnsetThreadLocalKey; | 29 static ThreadLocalKey kUnsetThreadLocalKey; |
28 static ThreadId kInvalidThreadId; | 30 static ThreadId kInvalidThreadId; |
29 | 31 |
30 typedef void (*ThreadStartFunction) (uword parameter); | 32 typedef void (*ThreadStartFunction) (uword parameter); |
31 | 33 |
32 // Start a thread running the specified function. Returns 0 if the | 34 // Start a thread running the specified function. Returns 0 if the |
33 // thread started successfuly and a system specific error code if | 35 // thread started successfuly and a system specific error code if |
34 // the thread failed to start. | 36 // the thread failed to start. |
(...skipping 16 matching lines...) Expand all Loading... |
51 | 53 |
52 class Mutex { | 54 class Mutex { |
53 public: | 55 public: |
54 Mutex(); | 56 Mutex(); |
55 ~Mutex(); | 57 ~Mutex(); |
56 | 58 |
57 void Lock(); | 59 void Lock(); |
58 bool TryLock(); | 60 bool TryLock(); |
59 void Unlock(); | 61 void Unlock(); |
60 | 62 |
| 63 #if defined(DEBUG) |
| 64 Isolate* Owner() const { return owner_; } |
| 65 #endif // defined(DEBUG) |
| 66 |
61 private: | 67 private: |
62 MutexData data_; | 68 MutexData data_; |
| 69 #if defined(DEBUG) |
| 70 Isolate* owner_; |
| 71 #endif // defined(DEBUG) |
63 | 72 |
64 DISALLOW_COPY_AND_ASSIGN(Mutex); | 73 DISALLOW_COPY_AND_ASSIGN(Mutex); |
65 }; | 74 }; |
66 | 75 |
67 | 76 |
68 class Monitor { | 77 class Monitor { |
69 public: | 78 public: |
70 enum WaitResult { | 79 enum WaitResult { |
71 kNotified, | 80 kNotified, |
72 kTimedOut | 81 kTimedOut |
(...skipping 19 matching lines...) Expand all Loading... |
92 MonitorData data_; // OS-specific data. | 101 MonitorData data_; // OS-specific data. |
93 | 102 |
94 DISALLOW_COPY_AND_ASSIGN(Monitor); | 103 DISALLOW_COPY_AND_ASSIGN(Monitor); |
95 }; | 104 }; |
96 | 105 |
97 | 106 |
98 } // namespace dart | 107 } // namespace dart |
99 | 108 |
100 | 109 |
101 #endif // VM_THREAD_H_ | 110 #endif // VM_THREAD_H_ |
OLD | NEW |