node/test/parallel/test-timers-next-tick.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

16 lines
495 B
JavaScript

'use strict';
const common = require('../common');
// This test documents an internal implementation detail of the Timers:
// since timers of different durations are stored in separate lists,
// a nextTick queue will clear after each list of timers. While this
// behaviour is not documented it could be relied on by Node's users.
setTimeout(common.mustCall(() => {
process.nextTick(() => { clearTimeout(t2); });
}), 1);
const t2 = setTimeout(common.mustNotCall(), 2);
common.busyLoop(5);