| 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 #ifndef VM_THREAD_INTERRUPTER_H_ | 5 #ifndef VM_THREAD_INTERRUPTER_H_ |
| 6 #define VM_THREAD_INTERRUPTER_H_ | 6 #define VM_THREAD_INTERRUPTER_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/signal_handler.h" | 9 #include "vm/signal_handler.h" |
| 10 #include "vm/os_thread.h" | 10 #include "vm/os_thread.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 static InterruptableThreadState* CurrentThreadState(); | 66 static InterruptableThreadState* CurrentThreadState(); |
| 67 | 67 |
| 68 // Interrupt a thread. | 68 // Interrupt a thread. |
| 69 static void InterruptThread(InterruptableThreadState* thread_state); | 69 static void InterruptThread(InterruptableThreadState* thread_state); |
| 70 | 70 |
| 71 private: | 71 private: |
| 72 static const intptr_t kMaxThreads = 4096; | 72 static const intptr_t kMaxThreads = 4096; |
| 73 static bool initialized_; | 73 static bool initialized_; |
| 74 static bool shutdown_; | 74 static bool shutdown_; |
| 75 static bool thread_running_; | 75 static bool thread_running_; |
| 76 static ThreadId interrupter_thread_id_; | 76 static ThreadJoinId interrupter_thread_id_; |
| 77 static Monitor* monitor_; | 77 static Monitor* monitor_; |
| 78 static intptr_t interrupt_period_; | 78 static intptr_t interrupt_period_; |
| 79 static intptr_t current_wait_time_; | 79 static intptr_t current_wait_time_; |
| 80 | 80 |
| 81 static bool InDeepSleep() { | 81 static bool InDeepSleep() { |
| 82 return current_wait_time_ == Monitor::kNoTimeout; | 82 return current_wait_time_ == Monitor::kNoTimeout; |
| 83 } | 83 } |
| 84 | 84 |
| 85 static InterruptableThreadState* _EnsureThreadStateCreated(); | 85 static InterruptableThreadState* _EnsureThreadStateCreated(); |
| 86 static void UpdateStateObject(ThreadInterruptCallback callback, void* data); | 86 static void UpdateStateObject(ThreadInterruptCallback callback, void* data); |
| 87 | 87 |
| 88 static void SetCurrentThreadState(InterruptableThreadState* state); | 88 static void SetCurrentThreadState(InterruptableThreadState* state); |
| 89 | 89 |
| 90 static void ThreadMain(uword parameters); | 90 static void ThreadMain(uword parameters); |
| 91 | 91 |
| 92 static void InstallSignalHandler(); | 92 static void InstallSignalHandler(); |
| 93 | 93 |
| 94 static void RemoveSignalHandler(); | 94 static void RemoveSignalHandler(); |
| 95 | 95 |
| 96 friend class ThreadInterrupterVisitIsolates; | 96 friend class ThreadInterrupterVisitIsolates; |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 void ThreadInterruptNoOp(const InterruptedThreadState& state, void* data); | 99 void ThreadInterruptNoOp(const InterruptedThreadState& state, void* data); |
| 100 | 100 |
| 101 } // namespace dart | 101 } // namespace dart |
| 102 | 102 |
| 103 #endif // VM_THREAD_INTERRUPTER_H_ | 103 #endif // VM_THREAD_INTERRUPTER_H_ |
| OLD | NEW |