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

Unified Diff: src/api.cc

Issue 154283002: V8 Microtask Queue & API (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: cleanup Created 6 years, 10 months 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
« include/v8.h ('K') | « include/v8.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 7a412df28dcfe13979722b1aa8bb41a6e10d0aa8..202c354d0db9551466b02e9be4832d311d32e944 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -6293,6 +6293,46 @@ void V8::AddCallCompletedCallback(CallCompletedCallback callback) {
}
+void V8::RunMicrotasks(Isolate* isolate) {
+ i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ i::HandleScope scope(i_isolate);
+ i::V8::RunMicrotasks(i_isolate);
+}
+
+
+static void ExternalMicrotaskFunctionCallback(
+ const v8::FunctionCallbackInfo<Value>& info) {
+ STATIC_ASSERT(
+ sizeof(ExternalMicrotaskCallback) == sizeof(v8::internal::Address));
+ ExternalMicrotaskCallback callback =
+ reinterpret_cast<ExternalMicrotaskCallback>(reinterpret_cast<intptr_t>(
+ info.Data().As<External>()->Value()));
+ (*callback)(info.GetIsolate());
+}
+
+
+void V8::EnqueueExternalMicrotask(Isolate* isolate,
+ ExternalMicrotaskCallback callback) {
dcarney 2014/02/11 07:47:13 No need for a new ExternalMicrotaskCallback type:
rafaelw 2014/02/11 20:37:43 Done.
+ i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
+ ENTER_V8(i_isolate);
+ i::HandleScope scope(i_isolate);
+ STATIC_ASSERT(
+ sizeof(ExternalMicrotaskCallback) == sizeof(v8::internal::Address));
+ Local<External> external_callback =
+ External::New(isolate,
+ reinterpret_cast<void*>(reinterpret_cast<intptr_t>(callback)));
+ Local<Function> local_handler = Function::New(isolate,
+ &ExternalMicrotaskFunctionCallback, external_callback);
+ i::Handle<i::Object> handler = Utils::OpenHandle(*local_handler);
+ i::V8::EnqueueExternalMicrotask(i_isolate, handler);
+}
+
+
+void V8::SetAutorunMicrotasks(Isolate* isolate, bool autorun) {
+ reinterpret_cast<i::Isolate*>(isolate)->set_autorun_microtasks(autorun);
+}
+
+
void V8::RemoveCallCompletedCallback(CallCompletedCallback callback) {
i::V8::RemoveCallCompletedCallback(callback);
}
« include/v8.h ('K') | « include/v8.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698