Index: src/js/microtaskq.js |
diff --git a/src/js/microtaskq.js b/src/js/microtaskq.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..163dee700ca9a684b4dc005a5fc2d08895c9dcb4 |
--- /dev/null |
+++ b/src/js/microtaskq.js |
@@ -0,0 +1,45 @@ |
+// Copyright 2012 the V8 project authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+(function(global, utils, extrasUtils) { |
+ |
+ "use strict"; |
+ |
+ %CheckIsBootstrapping(); |
+ |
+ // ---------------------------------------------------------- |
+ // Imports |
+ |
+ let InternalArray = utils.InternalArray; |
+ |
+ // ------------------------------------------------------------------- |
+ |
+ let microtaskQ = [] |
+ |
+ function MicrotaskEnq(task) { |
+ microtaskQ.push(task); |
+ } |
+ |
+ function MicrotaskRun() { |
+ for( var i = 0; i < microtaskQ.length; i ++) { |
+ try { |
+ microtaskQ[i](); |
+ } catch (e) {} |
+ } |
+ |
+ microtaskQ = []; |
+ } |
+ |
+ // ------------------------------------------------------------------- |
+ // Install exported functions. |
+ |
+ utils.Export(function(to) { |
+ to.MicrotaskEnq = MicrotaskEnq; |
+ }); |
+ |
+ %InstallToContext([ |
+ "microtask_run", MicrotaskRun, |
+ "microtask_enq", MicrotaskEnq |
+ ]); |
+}) |