| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 09c25bb commit 2e92f6f
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -39,17 +39,16 @@ | |||
| 39 | 39 | setupPrepareStackTrace(); | |
| 40 | 40 | ||
| 41 | 41 | const { | |
| 42 | + Array, | ||
| 42 | 43 | ArrayPrototypeConcat, | |
| 43 | - ArrayPrototypeFilter, | ||
| 44 | - ArrayPrototypeMap, | ||
| 44 | + ArrayPrototypeFill, | ||
| 45 | 45 | FunctionPrototypeCall, | |
| 46 | 46 | JSONParse, | |
| 47 | 47 | ObjectDefineProperty, | |
| 48 | 48 | ObjectDefineProperties, | |
| 49 | 49 | ObjectGetPrototypeOf, | |
| 50 | 50 | ObjectPreventExtensions, | |
| 51 | 51 | ObjectSetPrototypeOf, | |
| 52 | - ObjectValues, | ||
| 53 | 52 | ReflectGet, | |
| 54 | 53 | ReflectSet, | |
| 55 | 54 | SymbolToStringTag, | |
@@ -156,13 +155,12 @@ const rawMethods = internalBinding('process_methods'); | |||
| 156 | 155 | process._getActiveHandles = rawMethods._getActiveHandles; | |
| 157 | 156 | ||
| 158 | 157 | process.getActiveResourcesInfo = function() { | |
| 158 | + const timerCounts = internalTimers.getTimerCounts(); | ||
| 159 | 159 | return ArrayPrototypeConcat( | |
| 160 | 160 | rawMethods._getActiveRequestsInfo(), | |
| 161 | 161 | rawMethods._getActiveHandlesInfo(), | |
| 162 | - ArrayPrototypeMap( | ||
| 163 | - ArrayPrototypeFilter(ObjectValues(internalTimers.activeTimersMap), | ||
| 164 | - ({ resource }) => resource.hasRef()), | ||
| 165 | - ({ type }) => type)); | ||
| 162 | + ArrayPrototypeFill(new Array(timerCounts.timeoutCount), 'Timeout'), | ||
| 163 | + ArrayPrototypeFill(new Array(timerCounts.immediateCount), 'Immediate')); | ||
| 166 | 164 | }; | |
| 167 | 165 | ||
| 168 | 166 | // TODO(joyeecheung): remove these | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -139,12 +139,6 @@ const kRefed = Symbol('refed'); | |||
| 139 | 139 | // Create a single linked list instance only once at startup | |
| 140 | 140 | const immediateQueue = new ImmediateList(); | |
| 141 | 141 | ||
| 142 | - // Object map containing timers | ||
| 143 | - // | ||
| 144 | - // - key = asyncId | ||
| 145 | - // - value = { type, resource } | ||
| 146 | - const activeTimersMap = ObjectCreate(null); | ||
| 147 | - | ||
| 148 | 142 | let nextExpiry = Infinity; | |
| 149 | 143 | let refCount = 0; | |
| 150 | 144 | ||
@@ -166,7 +160,6 @@ function initAsyncResource(resource, type) { | |||
| 166 | 160 | resource[trigger_async_id_symbol] = getDefaultTriggerAsyncId(); | |
| 167 | 161 | if (initHooksExist()) | |
| 168 | 162 | emitInit(asyncId, type, triggerAsyncId, resource); | |
| 169 | - activeTimersMap[asyncId] = { type, resource }; | ||
| 170 | 163 | } | |
| 171 | 164 | ||
| 172 | 165 | // Timer constructor function. | |
@@ -478,7 +471,6 @@ function getTimerCallbacks(runNextTicks) { | |||
| 478 | 471 | ||
| 479 | 472 | if (destroyHooksExist()) | |
| 480 | 473 | emitDestroy(asyncId); | |
| 481 | - delete activeTimersMap[asyncId]; | ||
| 482 | 474 | ||
| 483 | 475 | outstandingQueue.head = immediate = immediate._idleNext; | |
| 484 | 476 | } | |
@@ -551,7 +543,6 @@ function getTimerCallbacks(runNextTicks) { | |||
| 551 | 543 | ||
| 552 | 544 | if (destroyHooksExist()) | |
| 553 | 545 | emitDestroy(asyncId); | |
| 554 | - delete activeTimersMap[asyncId]; | ||
| 555 | 546 | } | |
| 556 | 547 | continue; | |
| 557 | 548 | } | |
@@ -580,7 +571,6 @@ function getTimerCallbacks(runNextTicks) { | |||
| 580 | 571 | ||
| 581 | 572 | if (destroyHooksExist()) | |
| 582 | 573 | emitDestroy(asyncId); | |
| 583 | - delete activeTimersMap[asyncId]; | ||
| 584 | 574 | } | |
| 585 | 575 | } | |
| 586 | 576 | ||
@@ -648,6 +638,13 @@ class Immediate { | |||
| 648 | 638 | } | |
| 649 | 639 | } | |
| 650 | 640 | ||
| 641 | + function getTimerCounts() { | ||
| 642 | + return { | ||
| 643 | + timeoutCount: refCount, | ||
| 644 | + immediateCount: immediateInfo[kRefCount], | ||
| 645 | + }; | ||
| 646 | + } | ||
| 647 | + | ||
| 651 | 648 | module.exports = { | |
| 652 | 649 | TIMEOUT_MAX, | |
| 653 | 650 | kTimeout: Symbol('timeout'), // For hiding Timeouts on other internals. | |
@@ -670,9 +667,9 @@ module.exports = { | |||
| 670 | 667 | active, | |
| 671 | 668 | unrefActive, | |
| 672 | 669 | insert, | |
| 673 | - activeTimersMap, | ||
| 674 | 670 | timerListMap, | |
| 675 | 671 | timerListQueue, | |
| 676 | 672 | decRefCount, | |
| 677 | - incRefCount | ||
| 673 | + incRefCount, | ||
| 674 | + getTimerCounts, | ||
| 678 | 675 | }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -45,7 +45,6 @@ const { | |||
| 45 | 45 | kRefed, | |
| 46 | 46 | kHasPrimitive, | |
| 47 | 47 | getTimerDuration, | |
| 48 | - activeTimersMap, | ||
| 49 | 48 | timerListMap, | |
| 50 | 49 | timerListQueue, | |
| 51 | 50 | immediateQueue, | |
@@ -88,7 +87,6 @@ function unenroll(item) { | |||
| 88 | 87 | // Fewer checks may be possible, but these cover everything. | |
| 89 | 88 | if (destroyHooksExist() && item[async_id_symbol] !== undefined) | |
| 90 | 89 | emitDestroy(item[async_id_symbol]); | |
| 91 | - delete activeTimersMap[item[async_id_symbol]]; | ||
| 92 | 90 | ||
| 93 | 91 | L.remove(item); | |
| 94 | 92 | ||
@@ -331,7 +329,6 @@ function clearImmediate(immediate) { | |||
| 331 | 329 | if (destroyHooksExist() && immediate[async_id_symbol] !== undefined) { | |
| 332 | 330 | emitDestroy(immediate[async_id_symbol]); | |
| 333 | 331 | } | |
| 334 | - delete activeTimersMap[immediate[async_id_symbol]]; | ||
| 335 | 332 | ||
| 336 | 333 | immediate._onImmediate = null; | |
| 337 | 334 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments