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

Unified Diff: src/v8natives.js

Issue 154283002: V8 Microtask Queue & API (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: heapconst 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
« no previous file with comments | « src/v8.cc ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/v8natives.js
diff --git a/src/v8natives.js b/src/v8natives.js
index df663c025e927a79222e031ab8eee14d004f67a8..e4f0a3b8600acd10e51fa09f44ad371438066806 100644
--- a/src/v8natives.js
+++ b/src/v8natives.js
@@ -1889,10 +1889,30 @@ SetUpFunction();
// Eventually, we should move to a real event queue that allows to maintain
// relative ordering of different kinds of tasks.
-RunMicrotasks.runners = new InternalArray;
+function GetMicrotaskQueue() {
+ var microtaskState = %GetMicrotaskState();
+ if (IS_UNDEFINED(microtaskState.queue)) {
+ microtaskState.queue = new InternalArray;
+ }
+ return microtaskState.queue;
+}
function RunMicrotasks() {
while (%SetMicrotaskPending(false)) {
- for (var i in RunMicrotasks.runners) RunMicrotasks.runners[i]();
+ var microtaskState = %GetMicrotaskState();
+ if (IS_UNDEFINED(microtaskState.queue))
+ return;
+
+ var microtasks = microtaskState.queue;
+ microtaskState.queue = new InternalArray;
+
+ for (var i = 0; i < microtasks.length; i++) {
+ microtasks[i]();
+ }
}
}
+
+function EnqueueExternalMicrotask(fn) {
+ GetMicrotaskQueue().push(fn);
+ %SetMicrotaskPending(true);
+}
« no previous file with comments | « src/v8.cc ('k') | test/cctest/cctest.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698