Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2966)

Unified Diff: src/isolate.cc

Issue 796623003: Support multiple interrupt requests in v8 API. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/isolate.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « src/isolate.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698