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_WIN_H_ | 5 #ifndef PLATFORM_THREAD_WIN_H_ |
6 #define PLATFORM_THREAD_WIN_H_ | 6 #define PLATFORM_THREAD_WIN_H_ |
7 | 7 |
8 #if !defined(PLATFORM_THREAD_H_) | 8 #if !defined(PLATFORM_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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 DISALLOW_COPY_AND_ASSIGN(MutexData); | 47 DISALLOW_COPY_AND_ASSIGN(MutexData); |
48 }; | 48 }; |
49 | 49 |
50 | 50 |
51 class MonitorData { | 51 class MonitorData { |
52 private: | 52 private: |
53 MonitorData() {} | 53 MonitorData() {} |
54 ~MonitorData() {} | 54 ~MonitorData() {} |
55 | 55 |
56 CRITICAL_SECTION cs_; | 56 CRITICAL_SECTION cs_; |
57 // TODO(ager): Condition variables only available since Windows | 57 |
58 // Vista. Therefore, this is only a temporary solution. We will have | 58 // Condition variables are only available since Windows Vista. To |
59 // to implement simple condition variables for use in Windows XP and | 59 // support at least Windows XP, we implement our own condition |
60 // earlier. | 60 // variables using SetEvent on Event objects. |
61 CONDITION_VARIABLE cond_; | 61 |
| 62 // The notify_event_ is an auto-reset event which means that |
| 63 // SetEvent only wakes up one waiter. |
| 64 HANDLE notify_event_; |
| 65 |
| 66 // The notify_all_event_ is a manual-reset event which means that |
| 67 // SetEvent wakes up all waiters. |
| 68 HANDLE notify_all_event_; |
| 69 |
| 70 // Counter with protection used to determine the right time to reset |
| 71 // the notify_all_event_. |
| 72 CRITICAL_SECTION waiters_cs_; |
| 73 intptr_t waiters_; |
62 | 74 |
63 friend class Monitor; | 75 friend class Monitor; |
64 | 76 |
65 DISALLOW_ALLOCATION(); | 77 DISALLOW_ALLOCATION(); |
66 DISALLOW_COPY_AND_ASSIGN(MonitorData); | 78 DISALLOW_COPY_AND_ASSIGN(MonitorData); |
67 }; | 79 }; |
68 | 80 |
69 } // namespace dart | 81 } // namespace dart |
70 | 82 |
71 #endif // PLATFORM_THREAD_WIN_H_ | 83 #endif // PLATFORM_THREAD_WIN_H_ |
OLD | NEW |