Skip to content

Commit

Permalink
fixup! fixup! timers: use timerListMap and outstandingQueue to count …
Browse files Browse the repository at this point in the history
…timers

Signed-off-by: Darshan Sen <darshan.sen@postman.com>
  • Loading branch information
RaisinTen committed Dec 19, 2021
1 parent f973ffe commit 157ced8
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions lib/internal/bootstrap/node.js
Expand Up @@ -42,7 +42,6 @@ const {
Array,
ArrayPrototypeConcat,
ArrayPrototypeFill,
ArrayPrototypeForEach,
FunctionPrototypeCall,
JSONParse,
ObjectDefineProperty,
Expand Down Expand Up @@ -157,22 +156,21 @@ const rawMethods = internalBinding('process_methods');
process._getActiveHandles = rawMethods._getActiveHandles;

process.getActiveResourcesInfo = function() {
var timeoutCount = 0;
ArrayPrototypeForEach(ObjectValues(internalTimers.timerListMap),
(list) => {
var timer = list._idlePrev === list ?
null : list._idlePrev;
while (timer !== null) {
timeoutCount += timer.hasRef();
timer = timer._idlePrev === list ?
null : timer._idlePrev;
}
});

var immediateCount = 0;
let timeoutCount = 0;
const lists = ObjectValues(internalTimers.timerListMap);
for (let i = 0; i < lists.length; ++i) {
const list = lists[i];
let timer = list._idlePrev;
while (timer !== list) {
timeoutCount += timer.hasRef();
timer = timer._idlePrev;
}
}

let immediateCount = 0;
const queue = internalTimers.outstandingQueue.head !== null ?
internalTimers.outstandingQueue : internalTimers.immediateQueue;
var immediate = queue.head;
let immediate = queue.head;
while (immediate !== null) {
immediateCount += immediate.hasRef();
immediate = immediate._idleNext;
Expand Down

0 comments on commit 157ced8

Please sign in to comment.