Google is committed to advancing racial equity for Black communities. See how.

onDemand method

void onDemand (String name, OnDemandRootFn rootNodeCallback)

Mounts an Inspect file at .inspect whose contents are dynamically created by rootNodeCallback on each read.

If methods on this class are called multiple times with the same name, a unique number will be appended to the name.

Implementation

static void onDemand(String name, OnDemandRootFn rootNodeCallback) {
  var context = StartupContext.fromStartupInfo();
  var directory = context.outgoing.diagnosticsDir();
  var fileName = _nextInstanceWithName(name);
  var pseudoVmoNode = PseudoVmoFile.readOnly(() {
    var writer = VmoWriter.withSize(vmoSize);
    rootNodeCallback(RootNode(writer));
    return writer.vmo;
  });

  directory.addNode(fileName, pseudoVmoNode);
}