| Index: runtime/vm/thread.cc
|
| diff --git a/runtime/vm/thread.cc b/runtime/vm/thread.cc
|
| index a2af102a7ebc4736a645e2fd800e2c5b4ef5aa8a..c4bfd365c5351a6608cf78fc34500efcf6a2fd83 100644
|
| --- a/runtime/vm/thread.cc
|
| +++ b/runtime/vm/thread.cc
|
| @@ -66,6 +66,9 @@ void Thread::AddThreadToList(Thread* thread) {
|
| // Insert at head of list.
|
| thread->thread_list_next_ = thread_list_head_;
|
| thread_list_head_ = thread;
|
| +
|
| + // Make sure the thread interrupter is awake.
|
| + ThreadInterrupter::WakeUp();
|
| }
|
|
|
|
|
| @@ -180,6 +183,7 @@ Thread::Thread(bool init_vm_constants)
|
| : id_(OSThread::GetCurrentThreadId()),
|
| thread_interrupt_callback_(NULL),
|
| thread_interrupt_data_(NULL),
|
| + thread_interrupt_disabled_(0),
|
| isolate_(NULL),
|
| heap_(NULL),
|
| timeline_block_(NULL),
|
| @@ -452,6 +456,29 @@ void Thread::VisitObjectPointers(ObjectPointerVisitor* visitor) {
|
| }
|
|
|
|
|
| +void Thread::DisableThreadInterrupts() {
|
| + ASSERT(Thread::Current() == this);
|
| + AtomicOperations::FetchAndIncrement(&thread_interrupt_disabled_);
|
| +}
|
| +
|
| +
|
| +void Thread::EnableThreadInterrupts() {
|
| + ASSERT(Thread::Current() == this);
|
| + uintptr_t old =
|
| + AtomicOperations::FetchAndDecrement(&thread_interrupt_disabled_);
|
| + if (old == 1) {
|
| + // We just decremented from 1 to 0.
|
| + // Make sure the thread interrupter is awake.
|
| + ThreadInterrupter::WakeUp();
|
| + }
|
| +}
|
| +
|
| +
|
| +bool Thread::ThreadInterruptsEnabled() {
|
| + return AtomicOperations::LoadRelaxed(&thread_interrupt_disabled_) == 0;
|
| +}
|
| +
|
| +
|
| void Thread::SetThreadInterrupter(ThreadInterruptCallback callback,
|
| void* data) {
|
| ASSERT(Thread::Current() == this);
|
|
|