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 29 matching lines...) Expand all Loading... |
40 // allocated ThreadState. A thread's ThreadState is lazily allocated the first | 40 // allocated ThreadState. A thread's ThreadState is lazily allocated the first |
41 // time the thread is registered. A pointer to a thread's ThreadState is stored | 41 // time the thread is registered. A pointer to a thread's ThreadState is stored |
42 // in the list of threads registered to receive interrupts (threads_) and in | 42 // in the list of threads registered to receive interrupts (threads_) and in |
43 // thread local storage. When a thread's ThreadState is being modified, the | 43 // thread local storage. When a thread's ThreadState is being modified, the |
44 // thread local storage pointer is temporarily set to NULL while the | 44 // thread local storage pointer is temporarily set to NULL while the |
45 // modification is occurring. After the ThreadState has been updated, the | 45 // modification is occurring. After the ThreadState has been updated, the |
46 // thread local storage pointer is set again. This has an important side | 46 // thread local storage pointer is set again. This has an important side |
47 // effect: if the thread is interrupted by a signal handler during a ThreadState | 47 // effect: if the thread is interrupted by a signal handler during a ThreadState |
48 // update the signal handler will immediately return. | 48 // update the signal handler will immediately return. |
49 | 49 |
50 DEFINE_FLAG(bool, trace_thread_interrupter, false, | 50 DEFINE_FLAG(bool, trace_thread_interrupter, false, "Trace thread interrupter"); |
51 "Trace thread interrupter"); | |
52 | 51 |
53 bool ThreadInterrupter::initialized_ = false; | 52 bool ThreadInterrupter::initialized_ = false; |
54 bool ThreadInterrupter::shutdown_ = false; | 53 bool ThreadInterrupter::shutdown_ = false; |
55 bool ThreadInterrupter::thread_running_ = false; | 54 bool ThreadInterrupter::thread_running_ = false; |
56 bool ThreadInterrupter::woken_up_ = false; | 55 bool ThreadInterrupter::woken_up_ = false; |
57 ThreadJoinId ThreadInterrupter::interrupter_thread_id_ = | 56 ThreadJoinId ThreadInterrupter::interrupter_thread_id_ = |
58 OSThread::kInvalidThreadJoinId; | 57 OSThread::kInvalidThreadJoinId; |
59 Monitor* ThreadInterrupter::monitor_ = NULL; | 58 Monitor* ThreadInterrupter::monitor_ = NULL; |
60 intptr_t ThreadInterrupter::interrupt_period_ = 1000; | 59 intptr_t ThreadInterrupter::interrupt_period_ = 1000; |
61 intptr_t ThreadInterrupter::current_wait_time_ = Monitor::kNoTimeout; | 60 intptr_t ThreadInterrupter::current_wait_time_ = Monitor::kNoTimeout; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 // Signal to main thread we are exiting. | 221 // Signal to main thread we are exiting. |
223 MonitorLocker shutdown_ml(monitor_); | 222 MonitorLocker shutdown_ml(monitor_); |
224 thread_running_ = false; | 223 thread_running_ = false; |
225 shutdown_ml.Notify(); | 224 shutdown_ml.Notify(); |
226 } | 225 } |
227 } | 226 } |
228 | 227 |
229 #endif // !PRODUCT | 228 #endif // !PRODUCT |
230 | 229 |
231 } // namespace dart | 230 } // namespace dart |
OLD | NEW |