mirror of
https://github.com/nodejs/node.git
synced 2025-04-29 14:25:18 +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>
36 lines
754 B
JavaScript
36 lines
754 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const initHooks = require('./init-hooks');
|
|
const verifyGraph = require('./verify-graph');
|
|
const TIMEOUT = 1;
|
|
|
|
const hooks = initHooks();
|
|
hooks.enable();
|
|
|
|
let count = 0;
|
|
const iv1 = setInterval(common.mustCall(onfirstInterval, 3), TIMEOUT);
|
|
let iv2;
|
|
|
|
function onfirstInterval() {
|
|
if (++count === 3) {
|
|
clearInterval(iv1);
|
|
iv2 = setInterval(common.mustCall(onsecondInterval, 1), TIMEOUT + 1);
|
|
}
|
|
}
|
|
|
|
function onsecondInterval() {
|
|
clearInterval(iv2);
|
|
}
|
|
|
|
process.on('exit', onexit);
|
|
|
|
function onexit() {
|
|
hooks.disable();
|
|
verifyGraph(
|
|
hooks,
|
|
[ { type: 'Timeout', id: 'timeout:1', triggerAsyncId: null },
|
|
{ type: 'Timeout', id: 'timeout:2', triggerAsyncId: 'timeout:1' }]
|
|
);
|
|
}
|