release method

void release()

Releases a permit, returning it to the semaphore.

Implementation

void release() {
  if (_counter == 0) {
    throw new StateError("Unable to release semaphore.");
  }
  _counter--;
  if (_waitQueue.length > 0) {
    _counter++;
    var completer = _waitQueue.removeFirst();
    completer.complete();
  }
}