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 RUNTIME_BIN_THREAD_WIN_H_ | 5 #ifndef RUNTIME_BIN_THREAD_WIN_H_ |
6 #define RUNTIME_BIN_THREAD_WIN_H_ | 6 #define RUNTIME_BIN_THREAD_WIN_H_ |
7 | 7 |
8 #if !defined(RUNTIME_BIN_THREAD_H_) | 8 #if !defined(RUNTIME_BIN_THREAD_H_) |
9 #error Do not include thread_win.h directly; use thread.h instead. | 9 #error Do not include thread_win.h directly; use thread.h instead. |
10 #endif | 10 #endif |
(...skipping 18 matching lines...) Expand all Loading... |
29 return reinterpret_cast<uword>(TlsGetValue(key)); | 29 return reinterpret_cast<uword>(TlsGetValue(key)); |
30 } | 30 } |
31 | 31 |
32 friend class Thread; | 32 friend class Thread; |
33 friend unsigned int __stdcall ThreadEntry(void* data_ptr); | 33 friend unsigned int __stdcall ThreadEntry(void* data_ptr); |
34 | 34 |
35 DISALLOW_ALLOCATION(); | 35 DISALLOW_ALLOCATION(); |
36 DISALLOW_COPY_AND_ASSIGN(ThreadInlineImpl); | 36 DISALLOW_COPY_AND_ASSIGN(ThreadInlineImpl); |
37 }; | 37 }; |
38 | 38 |
39 | |
40 class MutexData { | 39 class MutexData { |
41 private: | 40 private: |
42 MutexData() {} | 41 MutexData() {} |
43 ~MutexData() {} | 42 ~MutexData() {} |
44 | 43 |
45 HANDLE semaphore_; | 44 HANDLE semaphore_; |
46 | 45 |
47 friend class Mutex; | 46 friend class Mutex; |
48 | 47 |
49 DISALLOW_ALLOCATION(); | 48 DISALLOW_ALLOCATION(); |
50 DISALLOW_COPY_AND_ASSIGN(MutexData); | 49 DISALLOW_COPY_AND_ASSIGN(MutexData); |
51 }; | 50 }; |
52 | 51 |
53 | |
54 class MonitorWaitData { | 52 class MonitorWaitData { |
55 public: | 53 public: |
56 static void ThreadExit(); | 54 static void ThreadExit(); |
57 | 55 |
58 private: | 56 private: |
59 explicit MonitorWaitData(HANDLE event) : event_(event), next_(NULL) {} | 57 explicit MonitorWaitData(HANDLE event) : event_(event), next_(NULL) {} |
60 ~MonitorWaitData() { | 58 ~MonitorWaitData() { |
61 CloseHandle(event_); | 59 CloseHandle(event_); |
62 ASSERT(next_ == NULL); | 60 ASSERT(next_ == NULL); |
63 } | 61 } |
64 | 62 |
65 // ThreadLocalKey used to fetch and store the MonitorWaitData object | 63 // ThreadLocalKey used to fetch and store the MonitorWaitData object |
66 // for a given thread. | 64 // for a given thread. |
67 static ThreadLocalKey monitor_wait_data_key_; | 65 static ThreadLocalKey monitor_wait_data_key_; |
68 | 66 |
69 // Auto-reset event used for waiting. | 67 // Auto-reset event used for waiting. |
70 HANDLE event_; | 68 HANDLE event_; |
71 // Link to next element in the singly-linked list of waiters. | 69 // Link to next element in the singly-linked list of waiters. |
72 MonitorWaitData* next_; | 70 MonitorWaitData* next_; |
73 | 71 |
74 friend class Monitor; | 72 friend class Monitor; |
75 friend class MonitorData; | 73 friend class MonitorData; |
76 friend class Thread; | 74 friend class Thread; |
77 | 75 |
78 | |
79 DISALLOW_COPY_AND_ASSIGN(MonitorWaitData); | 76 DISALLOW_COPY_AND_ASSIGN(MonitorWaitData); |
80 }; | 77 }; |
81 | 78 |
82 | |
83 class MonitorData { | 79 class MonitorData { |
84 private: | 80 private: |
85 MonitorData() {} | 81 MonitorData() {} |
86 ~MonitorData() {} | 82 ~MonitorData() {} |
87 | 83 |
88 // Helper methods to manipulate the list of waiters for this | 84 // Helper methods to manipulate the list of waiters for this |
89 // monitor. | 85 // monitor. |
90 void AddWaiter(MonitorWaitData* wait_data); | 86 void AddWaiter(MonitorWaitData* wait_data); |
91 void RemoveWaiter(MonitorWaitData* wait_data); | 87 void RemoveWaiter(MonitorWaitData* wait_data); |
92 void SignalAndRemoveFirstWaiter(); | 88 void SignalAndRemoveFirstWaiter(); |
(...skipping 20 matching lines...) Expand all Loading... |
113 friend unsigned int __stdcall ThreadEntry(void* data_ptr); | 109 friend unsigned int __stdcall ThreadEntry(void* data_ptr); |
114 | 110 |
115 DISALLOW_ALLOCATION(); | 111 DISALLOW_ALLOCATION(); |
116 DISALLOW_COPY_AND_ASSIGN(MonitorData); | 112 DISALLOW_COPY_AND_ASSIGN(MonitorData); |
117 }; | 113 }; |
118 | 114 |
119 } // namespace bin | 115 } // namespace bin |
120 } // namespace dart | 116 } // namespace dart |
121 | 117 |
122 #endif // RUNTIME_BIN_THREAD_WIN_H_ | 118 #endif // RUNTIME_BIN_THREAD_WIN_H_ |
OLD | NEW |