summaryrefslogtreecommitdiff
path: root/ext/web/02_timers.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/web/02_timers.js')
-rw-r--r--ext/web/02_timers.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/ext/web/02_timers.js b/ext/web/02_timers.js
index 27a9fcbde..c7dc90c82 100644
--- a/ext/web/02_timers.js
+++ b/ext/web/02_timers.js
@@ -386,9 +386,17 @@ function unrefTimer(id) {
core.unrefOpPromise(timerInfo.promise);
}
+// Defer to avoid starving the event loop. Not using queueMicrotask()
+// for that reason: it lets promises make forward progress but can
+// still starve other parts of the event loop.
+function defer(go) {
+ PromisePrototypeThen(op_void_async_deferred(), () => go());
+}
+
export {
clearInterval,
clearTimeout,
+ defer,
handleTimerMacrotask,
opNow,
refTimer,