node/test/parallel/test-timers-timeout-to-interval.js
Anatoli Papirovski 23a56e0c28
timers: use only a single TimerWrap instance
Hang all timer lists off a single TimerWrap and use the PriorityQueue
to manage expiration priorities. This makes the Timers code clearer,
consumes significantly less resources and improves performance.

PR-URL: https://github.com/nodejs/node/pull/20555
Fixes: https://github.com/nodejs/node/issues/16105
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2018-05-22 23:26:12 +04:00

13 lines
317 B
JavaScript

'use strict';
const common = require('../common');
// This isn't officially supported but nonetheless is something that is
// currently possible and as such it shouldn't cause the process to crash
const t = setTimeout(common.mustCall(() => {
if (t._repeat) {
clearInterval(t);
}
t._repeat = 1;
}, 2), 1);