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 PLATFORM_THREAD_H_ | 5 #ifndef PLATFORM_THREAD_H_ |
6 #define PLATFORM_THREAD_H_ | 6 #define PLATFORM_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_LINUX) | 11 #if defined(TARGET_OS_LINUX) |
12 #include "platform/thread_linux.h" | 12 #include "platform/thread_linux.h" |
13 #elif defined(TARGET_OS_MACOS) | 13 #elif defined(TARGET_OS_MACOS) |
14 #include "platform/thread_macos.h" | 14 #include "platform/thread_macos.h" |
15 #elif defined(TARGET_OS_WINDOWS) | 15 #elif defined(TARGET_OS_WINDOWS) |
16 #include "platform/thread_win.h" | 16 #include "platform/thread_win.h" |
17 #else | 17 #else |
18 #error Unknown target os. | 18 #error Unknown target os. |
19 #endif | 19 #endif |
20 | 20 |
21 namespace dart { | 21 namespace dart { |
22 | 22 |
23 class Thread { | 23 class Thread { |
24 public: | 24 public: |
| 25 static ThreadLocalKey kUnsetThreadLocalKey; |
| 26 |
25 typedef void (*ThreadStartFunction) (uword parameter); | 27 typedef void (*ThreadStartFunction) (uword parameter); |
26 | 28 |
27 // Start a thread running the specified function. Returns 0 if the | 29 // Start a thread running the specified function. Returns 0 if the |
28 // thread started successfuly and a system specific error code if | 30 // thread started successfuly and a system specific error code if |
29 // the thread failed to start. | 31 // the thread failed to start. |
30 static int Start(ThreadStartFunction function, uword parameters); | 32 static int Start(ThreadStartFunction function, uword parameters); |
| 33 |
| 34 static ThreadLocalKey CreateThreadLocal(); |
| 35 static void DeleteThreadLocal(ThreadLocalKey key); |
| 36 static uword GetThreadLocal(ThreadLocalKey key) { |
| 37 return ThreadInlineImpl::GetThreadLocal(key); |
| 38 } |
| 39 static void SetThreadLocal(ThreadLocalKey key, uword value); |
31 }; | 40 }; |
32 | 41 |
33 | 42 |
34 class Mutex { | 43 class Mutex { |
35 public: | 44 public: |
36 Mutex(); | 45 Mutex(); |
37 ~Mutex(); | 46 ~Mutex(); |
38 | 47 |
39 void Lock(); | 48 void Lock(); |
40 bool TryLock(); | 49 bool TryLock(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 private: | 81 private: |
73 MonitorData data_; // OS-specific data. | 82 MonitorData data_; // OS-specific data. |
74 | 83 |
75 DISALLOW_COPY_AND_ASSIGN(Monitor); | 84 DISALLOW_COPY_AND_ASSIGN(Monitor); |
76 }; | 85 }; |
77 | 86 |
78 } // namespace dart | 87 } // namespace dart |
79 | 88 |
80 | 89 |
81 #endif // PLATFORM_THREAD_H_ | 90 #endif // PLATFORM_THREAD_H_ |
OLD | NEW |