| 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/thread.h" | 10 #include "vm/thread.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 void* data); | 54 void* data); |
| 55 // Unregister the currently running thread for interrupts. | 55 // Unregister the currently running thread for interrupts. |
| 56 static void Unregister(); | 56 static void Unregister(); |
| 57 | 57 |
| 58 // Get the current thread state. Will create a thread state if one hasn't | 58 // Get the current thread state. Will create a thread state if one hasn't |
| 59 // been allocated. | 59 // been allocated. |
| 60 static InterruptableThreadState* GetCurrentThreadState(); | 60 static InterruptableThreadState* GetCurrentThreadState(); |
| 61 // Get the current thread state. Will not create one if one doesn't exist. | 61 // Get the current thread state. Will not create one if one doesn't exist. |
| 62 static InterruptableThreadState* CurrentThreadState(); | 62 static InterruptableThreadState* CurrentThreadState(); |
| 63 | 63 |
| 64 // Interrupt a thread. |
| 65 static void InterruptThread(InterruptableThreadState* thread_state); |
| 66 |
| 64 private: | 67 private: |
| 65 static const intptr_t kMaxThreads = 4096; | 68 static const intptr_t kMaxThreads = 4096; |
| 66 static bool initialized_; | 69 static bool initialized_; |
| 67 static bool shutdown_; | 70 static bool shutdown_; |
| 68 static bool thread_running_; | 71 static bool thread_running_; |
| 69 static ThreadId interrupter_thread_id_; | 72 static ThreadId interrupter_thread_id_; |
| 70 static Monitor* monitor_; | 73 static Monitor* monitor_; |
| 71 static intptr_t interrupt_period_; | 74 static intptr_t interrupt_period_; |
| 72 static ThreadLocalKey thread_state_key_; | 75 static ThreadLocalKey thread_state_key_; |
| 73 | 76 |
| 74 static InterruptableThreadState* _EnsureThreadStateCreated(); | 77 static InterruptableThreadState* _EnsureThreadStateCreated(); |
| 75 static void UpdateStateObject(ThreadInterruptCallback callback, void* data); | 78 static void UpdateStateObject(ThreadInterruptCallback callback, void* data); |
| 76 | 79 |
| 77 static void SetCurrentThreadState(InterruptableThreadState* state); | 80 static void SetCurrentThreadState(InterruptableThreadState* state); |
| 78 | 81 |
| 79 static void InterruptThread(InterruptableThreadState* thread_state); | |
| 80 static void ThreadMain(uword parameters); | 82 static void ThreadMain(uword parameters); |
| 81 | 83 |
| 82 static void InstallSignalHandler(); | 84 static void InstallSignalHandler(); |
| 83 | 85 |
| 84 friend class ThreadInterrupterVisitIsolates; | 86 friend class ThreadInterrupterVisitIsolates; |
| 85 }; | 87 }; |
| 86 | 88 |
| 87 void ThreadInterruptNoOp(const InterruptedThreadState& state, void* data); | 89 void ThreadInterruptNoOp(const InterruptedThreadState& state, void* data); |
| 88 | 90 |
| 89 } // namespace dart | 91 } // namespace dart |
| 90 | 92 |
| 91 #endif // VM_THREAD_INTERRUPTER_H_ | 93 #endif // VM_THREAD_INTERRUPTER_H_ |
| OLD | NEW |