mirror of
https://github.com/nodejs/node.git
synced 2024-11-30 23:43:09 +01:00
875a4d1a58
PR-URL: https://github.com/nodejs/node/pull/31569 Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
42 lines
826 B
JavaScript
42 lines
826 B
JavaScript
'use strict';
|
|
const {
|
|
Symbol
|
|
} = primordials;
|
|
const {
|
|
kUpdateTimer,
|
|
onStreamRead,
|
|
} = require('internal/stream_base_commons');
|
|
const { owner_symbol } = require('internal/async_hooks').symbols;
|
|
const { Readable } = require('stream');
|
|
|
|
const kHandle = Symbol('kHandle');
|
|
|
|
class HeapSnapshotStream extends Readable {
|
|
constructor(handle) {
|
|
super({ autoDestroy: true });
|
|
this[kHandle] = handle;
|
|
handle[owner_symbol] = this;
|
|
handle.onread = onStreamRead;
|
|
}
|
|
|
|
_read() {
|
|
if (this[kHandle])
|
|
this[kHandle].readStart();
|
|
}
|
|
|
|
_destroy() {
|
|
// Release the references on the handle so that
|
|
// it can be garbage collected.
|
|
this[kHandle][owner_symbol] = undefined;
|
|
this[kHandle] = undefined;
|
|
}
|
|
|
|
[kUpdateTimer]() {
|
|
// Does nothing
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
HeapSnapshotStream
|
|
};
|