OLD | NEW |
---|---|
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 VM_THREAD_H_ | 5 #ifndef RUNTIME_VM_THREAD_H_ |
6 #define VM_THREAD_H_ | 6 #define RUNTIME_VM_THREAD_H_ |
siva
2011/10/21 21:18:33
Why did you change this? If you look at all the ot
jrgfogh
2011/10/24 09:20:42
A presubmit script told me to do it when I tried t
Søren Gjesse
2011/10/26 12:07:10
That is annoying. When this error is the only one
| |
7 | 7 |
8 #include "vm/assert.h" | 8 #include "vm/assert.h" |
9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
10 #include "vm/globals.h" | 10 #include "vm/globals.h" |
11 | 11 |
12 // Declare the OS-specific types ahead of defining the generic classes. | 12 // Declare the OS-specific types ahead of defining the generic classes. |
13 #if defined(TARGET_OS_LINUX) | 13 #if defined(TARGET_OS_LINUX) |
14 #include "vm/thread_linux.h" | 14 #include "vm/thread_linux.h" |
15 #elif defined(TARGET_OS_MACOS) | 15 #elif defined(TARGET_OS_MACOS) |
16 #include "vm/thread_macos.h" | 16 #include "vm/thread_macos.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 | 63 |
64 static const int64_t kNoTimeout = 0; | 64 static const int64_t kNoTimeout = 0; |
65 | 65 |
66 Monitor(); | 66 Monitor(); |
67 ~Monitor(); | 67 ~Monitor(); |
68 | 68 |
69 void Enter(); | 69 void Enter(); |
70 void Exit(); | 70 void Exit(); |
71 | 71 |
72 // Wait for notification or timeout. | 72 // Wait for notification or timeout. |
73 // May return too early due to spurious wakeups. Callers should test for this. | |
siva
2011/10/21 21:18:33
I think this comment is not necessary.
jrgfogh
2011/10/24 09:20:42
I disagree, since it affects the semantics. I woul
| |
73 WaitResult Wait(int64_t millis); | 74 WaitResult Wait(int64_t millis); |
74 | 75 |
75 // Notify waiting threads. | 76 // Notify waiting threads. |
76 void Notify(); | 77 void Notify(); |
77 void NotifyAll(); | 78 void NotifyAll(); |
78 | 79 |
79 private: | 80 private: |
80 MonitorData data_; // OS-specific data. | 81 MonitorData data_; // OS-specific data. |
81 | 82 |
82 DISALLOW_COPY_AND_ASSIGN(Monitor); | 83 DISALLOW_COPY_AND_ASSIGN(Monitor); |
(...skipping 28 matching lines...) Expand all Loading... | |
111 ASSERT(monitor != NULL); | 112 ASSERT(monitor != NULL); |
112 // TODO(iposva): Consider adding a no GC scope here. | 113 // TODO(iposva): Consider adding a no GC scope here. |
113 monitor_->Enter(); | 114 monitor_->Enter(); |
114 } | 115 } |
115 | 116 |
116 virtual ~MonitorLocker() { | 117 virtual ~MonitorLocker() { |
117 monitor_->Exit(); | 118 monitor_->Exit(); |
118 // TODO(iposva): Consider decrementing the no GC scope here. | 119 // TODO(iposva): Consider decrementing the no GC scope here. |
119 } | 120 } |
120 | 121 |
122 // May return too early due to spurious wakeups. Callers should test for this. | |
siva
2011/10/21 21:18:33
Ditto.
jrgfogh
2011/10/24 09:20:42
Ditto.
| |
121 Monitor::WaitResult Wait(int64_t millis = Monitor::kNoTimeout) { | 123 Monitor::WaitResult Wait(int64_t millis = Monitor::kNoTimeout) { |
122 return monitor_->Wait(millis); | 124 return monitor_->Wait(millis); |
123 } | 125 } |
124 | 126 |
125 void Notify() { | 127 void Notify() { |
126 monitor_->Notify(); | 128 monitor_->Notify(); |
127 } | 129 } |
128 | 130 |
129 void NotifyAll() { | 131 void NotifyAll() { |
130 monitor_->NotifyAll(); | 132 monitor_->NotifyAll(); |
131 } | 133 } |
132 | 134 |
133 private: | 135 private: |
134 Monitor* const monitor_; | 136 Monitor* const monitor_; |
135 | 137 |
136 DISALLOW_COPY_AND_ASSIGN(MonitorLocker); | 138 DISALLOW_COPY_AND_ASSIGN(MonitorLocker); |
137 }; | 139 }; |
138 | 140 |
139 } // namespace dart | 141 } // namespace dart |
140 | 142 |
141 | 143 |
142 #endif // VM_THREAD_H_ | 144 #endif // RUNTIME_VM_THREAD_H_ |
siva
2011/10/21 21:18:33
ditto.
jrgfogh
2011/10/24 09:20:42
ditto.
| |
OLD | NEW |