• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const {
3  Symbol,
4} = primordials;
5const {
6  kUpdateTimer,
7  onStreamRead,
8} = require('internal/stream_base_commons');
9const { owner_symbol } = require('internal/async_hooks').symbols;
10const { Readable } = require('stream');
11
12const kHandle = Symbol('kHandle');
13
14class HeapSnapshotStream extends Readable {
15  constructor(handle) {
16    super({ autoDestroy: true });
17    this[kHandle] = handle;
18    handle[owner_symbol] = this;
19    handle.onread = onStreamRead;
20  }
21
22  _read() {
23    if (this[kHandle])
24      this[kHandle].readStart();
25  }
26
27  _destroy() {
28    // Release the references on the handle so that
29    // it can be garbage collected.
30    this[kHandle][owner_symbol] = undefined;
31    this[kHandle] = undefined;
32  }
33
34  [kUpdateTimer]() {
35    // Does nothing
36  }
37}
38
39module.exports = {
40  HeapSnapshotStream,
41};
42