close method

Future<void> close({
  1. bool cancelPending = true,
})

Closes the limiter to new work and waits until it becomes idle.

If cancelPending is true, queued tasks are canceled immediately.

Implementation

Future<void> close({bool cancelPending = true}) async {
  _isClosed = true;
  if (cancelPending) {
    clearQueue();
  } else {
    _isPaused = false;
    _tryResumeNext();
  }
  await onIdle;
}