release method

void release()

Releases a permit, returning it to the semaphore.

Implementation

void release() {
  if (_currentCount == 0) {
    throw StateError('Unable to release semaphore');
  }

  _currentCount--;
  if (_waitQueue.isNotEmpty) {
    _currentCount++;
    final completer = _waitQueue.removeFirst();
    completer.complete();
  }
}