start method

Future<void> start()

Starts the processing isolate if not already running.

Implementation

Future<void> start() async {
  if (_starting != null) {
    await _starting;
    return;
  }
  if (_isolate != null) {
    return;
  }

  final completer = Completer<void>();
  _starting = completer.future;

  final receivePort = ReceivePort();
  _isolate = await Isolate.spawn(
    pyannoteIsolateEntryPoint,
    receivePort.sendPort,
    onError: receivePort.sendPort,
  );

  final sendPort = await receivePort.first as SendPort;
  _sendPort = sendPort;

  completer.complete();
  _starting = null;
}