| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 | 68 |
| 69 | 69 |
| 70 void ThreadInterrupter::Startup() { | 70 void ThreadInterrupter::Startup() { |
| 71 ASSERT(initialized_); | 71 ASSERT(initialized_); |
| 72 if (FLAG_trace_thread_interrupter) { | 72 if (FLAG_trace_thread_interrupter) { |
| 73 OS::Print("ThreadInterrupter starting up.\n"); | 73 OS::Print("ThreadInterrupter starting up.\n"); |
| 74 } | 74 } |
| 75 ASSERT(interrupter_thread_id_ == OSThread::kInvalidThreadJoinId); | 75 ASSERT(interrupter_thread_id_ == OSThread::kInvalidThreadJoinId); |
| 76 { | 76 { |
| 77 MonitorLocker startup_ml(monitor_); | 77 MonitorLocker startup_ml(monitor_); |
| 78 OSThread::Start(ThreadMain, 0); | 78 OSThread::Start("ThreadInterrupter", ThreadMain, 0); |
| 79 while (!thread_running_) { | 79 while (!thread_running_) { |
| 80 startup_ml.Wait(); | 80 startup_ml.Wait(); |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 ASSERT(interrupter_thread_id_ != OSThread::kInvalidThreadJoinId); | 83 ASSERT(interrupter_thread_id_ != OSThread::kInvalidThreadJoinId); |
| 84 if (FLAG_trace_thread_interrupter) { | 84 if (FLAG_trace_thread_interrupter) { |
| 85 OS::Print("ThreadInterrupter running.\n"); | 85 OS::Print("ThreadInterrupter running.\n"); |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 current_wait_time_ = interrupt_period_; | 175 current_wait_time_ = interrupt_period_; |
| 176 } | 176 } |
| 177 | 177 |
| 178 // Reset count before interrupting any threads. | 178 // Reset count before interrupting any threads. |
| 179 interrupted_thread_count = 0; | 179 interrupted_thread_count = 0; |
| 180 | 180 |
| 181 // Temporarily drop the monitor while we interrupt threads. | 181 // Temporarily drop the monitor while we interrupt threads. |
| 182 monitor_->Exit(); | 182 monitor_->Exit(); |
| 183 | 183 |
| 184 { | 184 { |
| 185 ThreadIterator it; | 185 OSThreadIterator it; |
| 186 while (it.HasNext()) { | 186 while (it.HasNext()) { |
| 187 Thread* thread = it.Next(); | 187 OSThread* thread = it.Next(); |
| 188 if (thread->ThreadInterruptsEnabled()) { | 188 if (thread->ThreadInterruptsEnabled()) { |
| 189 interrupted_thread_count++; | 189 interrupted_thread_count++; |
| 190 InterruptThread(thread); | 190 InterruptThread(thread); |
| 191 } | 191 } |
| 192 } | 192 } |
| 193 } | 193 } |
| 194 | 194 |
| 195 // Take the monitor lock again. | 195 // Take the monitor lock again. |
| 196 monitor_->Enter(); | 196 monitor_->Enter(); |
| 197 | 197 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 216 } | 216 } |
| 217 { | 217 { |
| 218 // Signal to main thread we are exiting. | 218 // Signal to main thread we are exiting. |
| 219 MonitorLocker shutdown_ml(monitor_); | 219 MonitorLocker shutdown_ml(monitor_); |
| 220 thread_running_ = false; | 220 thread_running_ = false; |
| 221 shutdown_ml.Notify(); | 221 shutdown_ml.Notify(); |
| 222 } | 222 } |
| 223 } | 223 } |
| 224 | 224 |
| 225 } // namespace dart | 225 } // namespace dart |
| OLD | NEW |