Expand description
Node timers and timers/promises modules.
require('timers') re-exports the SAME timer primitives that already exist as
globals (setTimeout/setInterval/setImmediate + their clear*), so this
module owns NO queue of its own: every method delegates straight to
builtins::call_builtin_function, which schedules onto the single shared
JsHost.macrotasks queue. timers.foo(...) is therefore observably identical
to the global foo(...).
require('timers/promises') returns the promise-based variants: setTimeout
and setImmediate resolve a Promise after the delay instead of invoking a
callback. They are built on the SAME two substrates — the global timer
scheduler and the @@presolve:<id> native-continuation convention that
builtins.rs uses for Promise resolve reactions — so no new mechanism is
introduced: a timer is scheduled whose callback is the promise’s resolver.
Constants§
- METHODS
- Methods of the
timersmodule. Each name is also a global;callforwards to the identical global implementation, so there is one timer queue, not two. - PROMISES_
METHODS - Methods of the
timers/promisesmodule (its namespace name carries no., sostdlib::is_methodtreats the whole"timers/promises"as the namespace).
Functions§
- call
- Dispatch a
timers.<method>call by delegating to the matching global timer builtin.clearImmediatehas no distinct global handler (the loop cancels by id regardless of kind), so it maps toclearTimeout. - promises_
call - Dispatch a
timers/promises.<method>call.