diff options
Diffstat (limited to 'ext/web/02_timers.js')
-rw-r--r-- | ext/web/02_timers.js | 8 |
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, |