Index: src/isolate.cc |
diff --git a/src/isolate.cc b/src/isolate.cc |
index 4c30fd539ec7c8296217f9e1efb628b15cc87fb6..69a6b5d614377e09509f51c69feeb64edc4c292c 100644 |
--- a/src/isolate.cc |
+++ b/src/isolate.cc |
@@ -917,22 +917,26 @@ void Isolate::CancelTerminateExecution() { |
} |
-void Isolate::InvokeApiInterruptCallback() { |
- // Note: callback below should be called outside of execution access lock. |
- InterruptCallback callback = NULL; |
- void* data = NULL; |
- { |
- ExecutionAccess access(this); |
- callback = api_interrupt_callback_; |
- data = api_interrupt_callback_data_; |
- api_interrupt_callback_ = NULL; |
- api_interrupt_callback_data_ = NULL; |
- } |
+void Isolate::RequestInterrupt(InterruptCallback callback, void* data) { |
+ ExecutionAccess access(this); |
+ api_interrupts_queue_.push(InterruptEntry(callback, data)); |
+ stack_guard()->RequestApiInterrupt(); |
+} |
- if (callback != NULL) { |
+ |
+void Isolate::InvokeApiInterruptCallbacks() { |
+ // Note: callback below should be called outside of execution access lock. |
+ while (true) { |
+ InterruptEntry entry; |
+ { |
+ ExecutionAccess access(this); |
+ if (api_interrupts_queue_.empty()) return; |
+ entry = api_interrupts_queue_.front(); |
+ api_interrupts_queue_.pop(); |
+ } |
VMState<EXTERNAL> state(this); |
HandleScope handle_scope(this); |
- callback(reinterpret_cast<v8::Isolate*>(this), data); |
+ entry.first(reinterpret_cast<v8::Isolate*>(this), entry.second); |
} |
} |