| 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. | |
| 26 typedef void (*ThreadStartFunction) (uword parameter); | 25 typedef void (*ThreadStartFunction) (uword parameter); |
| 27 | 26 |
| 28 // TODO(iposva): Define the proper interface for spawning and killing threads. | 27 // Start a thread running the specified function. Returns 0 if the |
| 29 Thread(ThreadStartFunction function, uword parameters); | 28 // thread started successfuly and a system specific error code if |
| 30 ~Thread(); | 29 // the thread failed to start. |
| 31 | 30 static int Start(ThreadStartFunction function, uword parameters); |
| 32 private: | |
| 33 ThreadData data_; | |
| 34 | |
| 35 DISALLOW_COPY_AND_ASSIGN(Thread); | |
| 36 }; | 31 }; |
| 37 | 32 |
| 38 | 33 |
| 39 class Mutex { | 34 class Mutex { |
| 40 public: | 35 public: |
| 41 Mutex(); | 36 Mutex(); |
| 42 ~Mutex(); | 37 ~Mutex(); |
| 43 | 38 |
| 44 void Lock(); | 39 void Lock(); |
| 45 bool TryLock(); | 40 bool TryLock(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 private: | 72 private: |
| 78 MonitorData data_; // OS-specific data. | 73 MonitorData data_; // OS-specific data. |
| 79 | 74 |
| 80 DISALLOW_COPY_AND_ASSIGN(Monitor); | 75 DISALLOW_COPY_AND_ASSIGN(Monitor); |
| 81 }; | 76 }; |
| 82 | 77 |
| 83 } // namespace dart | 78 } // namespace dart |
| 84 | 79 |
| 85 | 80 |
| 86 #endif // PLATFORM_THREAD_H_ | 81 #endif // PLATFORM_THREAD_H_ |
| OLD | NEW |