start method

Future<Stream<O>> start()
override

Start up the ProcessGroup. Call this before sending any data to the ProcessGroup

Implementation

Future<Stream<O>> start() async {
  // custom receive port to be shared across all processes
  var customRecvPort = ReceivePort();

  for (var proc in _procGroup) {
    var _ = await proc.start(
      customMainRecvPort: customRecvPort,
      onExit: () {
        // keep track of active processes and close the receive port when all
        // processes are dead
        _activeProcCount--;

        if (_activeProcCount <= 0) {
          customRecvPort.close();
        }
      },
    );
  }

  stream = customRecvPort.getBroadcastStream().cast<O>();

  return stream;
}