stream method

Future<Stream<List<int>>> stream({
  1. int begin = 0,
  2. int? end,
  3. required File createFragmentFile(),
  4. IOStreamedResponse? clientResponse,
  5. required IOClient client,
  6. required Request clientRequest,
})

Synchronous the _stream entry

Implementation

Future<Stream<List<int>>> stream({
  int begin = 0,
  int? end,
  required File Function() createFragmentFile,
  IOStreamedResponse? clientResponse,
  required IOClient client,
  required http.Request clientRequest,
}) async {
  Future? prev = _lastEntrant;
  Completer completer = Completer.sync();
  _lastEntrant = completer.future;

  if (prev != null) {
    await prev;
  }
  Stream<List<int>> result =
      _stream(begin: begin, end: end, createFragmentFile: createFragmentFile, clientRequest: clientRequest, clientResponse: clientResponse, client: client);
  if (identical(_lastEntrant, completer.future)) {
    _lastEntrant = null;
  }
  completer.complete();
  return result;
}