addChunk method

Future<void> addChunk(
  1. ParsedRowBuffer chunk
)

Adds a chunk. When maxBufferSize is set and the buffer is full, waits until the consumer reduces the count below maxBufferSize.

Implementation

Future<void> addChunk(ParsedRowBuffer chunk) async {
  if (_controller.isClosed) return;
  if (_isPaused && maxBufferSize == null) return;

  if (maxBufferSize != null && _pendingCount >= maxBufferSize!) {
    _resumeCompleter ??= Completer<void>();
    await _resumeCompleter!.future;
    if (_controller.isClosed) return;
  }
  _pendingCount++;
  if (!_controller.isClosed) {
    _controller.add(chunk);
  }
}