dispose method

Future<void> dispose()

Stops the worker. Using it afterwards throws.

Implementation

Future<void> dispose() async {
  if (_closed) return;
  try {
    await _send('dispose', (_) {});
  } catch (_) {
    // A worker that has already died needs no telling.
  }
  _closed = true;
  _worker.terminate();
}