OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 #include "vm/thread_interrupter.h" | 5 #include "vm/thread_interrupter.h" |
6 | 6 |
7 #include "vm/flags.h" | 7 #include "vm/flags.h" |
8 #include "vm/lockers.h" | 8 #include "vm/lockers.h" |
9 #include "vm/os.h" | 9 #include "vm/os.h" |
10 #include "vm/simulator.h" | 10 #include "vm/simulator.h" |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 // Signal to main thread we are ready. | 156 // Signal to main thread we are ready. |
157 MonitorLocker startup_ml(monitor_); | 157 MonitorLocker startup_ml(monitor_); |
158 OSThread* os_thread = OSThread::Current(); | 158 OSThread* os_thread = OSThread::Current(); |
159 ASSERT(os_thread != NULL); | 159 ASSERT(os_thread != NULL); |
160 interrupter_thread_id_ = os_thread->join_id(); | 160 interrupter_thread_id_ = os_thread->join_id(); |
161 thread_running_ = true; | 161 thread_running_ = true; |
162 startup_ml.Notify(); | 162 startup_ml.Notify(); |
163 } | 163 } |
164 { | 164 { |
165 intptr_t interrupted_thread_count = 0; | 165 intptr_t interrupted_thread_count = 0; |
| 166 MonitorLocker wait_ml(monitor_); |
166 current_wait_time_ = interrupt_period_; | 167 current_wait_time_ = interrupt_period_; |
167 MonitorLocker wait_ml(monitor_); | |
168 while (!shutdown_) { | 168 while (!shutdown_) { |
169 intptr_t r = wait_ml.WaitMicros(current_wait_time_); | 169 intptr_t r = wait_ml.WaitMicros(current_wait_time_); |
170 | 170 |
171 if (shutdown_) { | 171 if (shutdown_) { |
172 break; | 172 break; |
173 } | 173 } |
174 | 174 |
175 if ((r == Monitor::kNotified) && InDeepSleep()) { | 175 if ((r == Monitor::kNotified) && InDeepSleep()) { |
176 // Woken up from deep sleep. | 176 // Woken up from deep sleep. |
177 ASSERT(interrupted_thread_count == 0); | 177 ASSERT(interrupted_thread_count == 0); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 // Signal to main thread we are exiting. | 222 // Signal to main thread we are exiting. |
223 MonitorLocker shutdown_ml(monitor_); | 223 MonitorLocker shutdown_ml(monitor_); |
224 thread_running_ = false; | 224 thread_running_ = false; |
225 shutdown_ml.Notify(); | 225 shutdown_ml.Notify(); |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
229 #endif // !PRODUCT | 229 #endif // !PRODUCT |
230 | 230 |
231 } // namespace dart | 231 } // namespace dart |
OLD | NEW |