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 // Function to be called on thread start. | 25 static const int64_t kNoTimeout = 0; |
26 static const ThreadHandle kInvalidThreadHandle; | |
27 | |
26 typedef void (*ThreadStartFunction) (uword parameter); | 28 typedef void (*ThreadStartFunction) (uword parameter); |
27 | 29 |
28 // TODO(iposva): Define the proper interface for spawning and killing threads. | 30 // Start a thread running the specified function. |
29 Thread(ThreadStartFunction function, uword parameters); | 31 static ThreadHandle Start(ThreadStartFunction function, uword parameters); |
30 ~Thread(); | 32 // Wait for thread termination or timeout. |
31 | 33 static void Join(ThreadHandle thread); |
Ivan Posva
2012/01/20 16:45:55
Please remove the Join functionality it is not rea
Søren Gjesse
2012/01/23 13:14:58
Why is Join not useful? Especially for testing I h
| |
32 private: | |
33 ThreadData data_; | |
34 | |
35 DISALLOW_COPY_AND_ASSIGN(Thread); | |
36 }; | 34 }; |
37 | 35 |
38 | 36 |
39 class Mutex { | 37 class Mutex { |
40 public: | 38 public: |
41 Mutex(); | 39 Mutex(); |
42 ~Mutex(); | 40 ~Mutex(); |
43 | 41 |
44 void Lock(); | 42 void Lock(); |
45 bool TryLock(); | 43 bool TryLock(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 private: | 75 private: |
78 MonitorData data_; // OS-specific data. | 76 MonitorData data_; // OS-specific data. |
79 | 77 |
80 DISALLOW_COPY_AND_ASSIGN(Monitor); | 78 DISALLOW_COPY_AND_ASSIGN(Monitor); |
81 }; | 79 }; |
82 | 80 |
83 } // namespace dart | 81 } // namespace dart |
84 | 82 |
85 | 83 |
86 #endif // PLATFORM_THREAD_H_ | 84 #endif // PLATFORM_THREAD_H_ |
OLD | NEW |