threadCount property

int threadCount

The maximum amount of "thread"s to use to complete the futures in batches.

Note that these "threads" are not actual Dart threads; they run in the main isolate/event loop.

Implementation

int get threadCount => _threadCount;
void threadCount=(int newThreadCount)

Sets the threadCount.

This must be greater than zero. If the count is reduced, running threads will exit after they finish resolving their current futures until the new thread count is met.

Implementation

set threadCount(int newThreadCount) {
  if (newThreadCount == _threadCount) return;

  assert(newThreadCount > 0, 'At least one thread must be provided!');
  _threadCount = newThreadCount;

  // Create additional threads if the new value is higher than the existing
  // amount. If it's not, just assign it and the next threads to finish
  // tasks will exit until the running amount is correct.
  if (_threadCount > _threads.length) {
    _createMissingThreads();
  }
}