shutdown method

void shutdown()

Shuts down the Downloader.

Implementation

void shutdown() {
  if (!_isClosed) {
    _isClosed = true;
    _toSpawnedIsolate.send(_shutdownCode);

    // NOTE: _activeRequests only has requests that are sent, but not yet processed. So, if there
    // is a request being processed, while shutdown is called, it will be processed and when it is
    // returned, the _fromSpawnedIsolate port will be closed in _verifyRequestProcessing.
    if (_activeRequests.isEmpty) {
      _fromSpawnedIsolate.close();
    }
  }
}