add method

void add ([int amount = 1 ])

Adds delta, which may be negative, to the WaitGroup counter. If a wait Future is open and the counter becomes zero, the future is released. If the counter goes negative, it throws.

Implementation

void add([int amount = 1]) {
  if (_counter + amount < 0) {
    throw new StateError("WaitGroup counter cannot go negative.");
  }
  _counter += amount;
  if (_counter == 0 && _completer != null) {
    _completer.complete();
  }
}