diff options
author | James M Snell <jasnell@gmail.com> | 2018-02-16 12:12:17 -0800 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2018-02-26 13:55:51 -0800 |
commit | 009e41826f47c595ca994f673023f9380198be36 (patch) | |
tree | 889df543b6673d398476c62500223eb88e545742 /lib/perf_hooks.js | |
parent | 9e509b622bbdc14b7153d006f57043f268017138 (diff) | |
download | android-node-v8-009e41826f47c595ca994f673023f9380198be36.tar.gz android-node-v8-009e41826f47c595ca994f673023f9380198be36.tar.bz2 android-node-v8-009e41826f47c595ca994f673023f9380198be36.zip |
perf_hooks: make PerformanceObserver an AsyncResource
PR-URL: https://github.com/nodejs/node/pull/18789
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Diffstat (limited to 'lib/perf_hooks.js')
-rw-r--r-- | lib/perf_hooks.js | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/perf_hooks.js b/lib/perf_hooks.js index 6fd6e4a6b7..025fa9edd0 100644 --- a/lib/perf_hooks.js +++ b/lib/perf_hooks.js @@ -36,6 +36,7 @@ const { NODE_PERFORMANCE_MILESTONE_PRELOAD_MODULE_LOAD_END } = constants; +const { AsyncResource } = require('async_hooks'); const L = require('internal/linkedlist'); const kInspect = require('internal/util').customInspectSymbol; const { inherits } = require('util'); @@ -317,12 +318,13 @@ class PerformanceObserverEntryList { } } -class PerformanceObserver { +class PerformanceObserver extends AsyncResource { constructor(callback) { if (typeof callback !== 'function') { const errors = lazyErrors(); throw new errors.TypeError('ERR_INVALID_CALLBACK'); } + super('PerformanceObserver'); Object.defineProperties(this, { [kTypes]: { enumerable: false, @@ -568,7 +570,7 @@ function getObserversList(type) { function doNotify() { this[kQueued] = false; - this[kCallback](this[kBuffer], this); + this.runInAsyncScope(this[kCallback], this, this[kBuffer], this); this[kBuffer][kEntries] = []; L.init(this[kBuffer][kEntries]); } |