mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 18:44:40 +00:00

Refactor Timers to behave more similarly to Immediates by having a single uv_timer_t handle which is stored on the Environment. No longer expose timers in a public binding and instead make it part of the internalBinding. PR-URL: https://github.com/nodejs/node/pull/20894 Fixes: https://github.com/nodejs/node/issues/10154 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Gus Caplan <me@gus.host>
24 lines
529 B
JavaScript
24 lines
529 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
let cntr = 0;
|
|
let first;
|
|
const t = setInterval(() => {
|
|
cntr++;
|
|
if (cntr === 1) {
|
|
common.busyLoop(100);
|
|
// ensure that the event loop passes before the second interval
|
|
setImmediate(() => assert.strictEqual(cntr, 1));
|
|
first = Date.now();
|
|
} else if (cntr === 2) {
|
|
assert(Date.now() - first < 100);
|
|
clearInterval(t);
|
|
}
|
|
}, 100);
|
|
const t2 = setInterval(() => {
|
|
if (cntr === 2) {
|
|
clearInterval(t2);
|
|
}
|
|
}, 100);
|