close method

void close()

Closes this pool: the queued computations fail with a StateError, the running ones complete, then the workers exit.

Implementation

void close() {
  if (_closed) return;
  _closed = true;

  while (_queue.isNotEmpty) {
    _queue.removeFirst()._fail(
      StateError("Closed `APIIsolatePool`: $debugName"),
      StackTrace.current,
    );
  }

  for (var w in _workers.toList()) {
    w._shutdown();
  }
}