acquire method

Future<void> acquire()

Implementation

Future<void> acquire() {
  if (awaitChecking) {
    if (isHeld) {
      return Future.error(StateError(
          'Maybe you missed an await? Lock is already held by:\n$_stack'));
    } else {
      _stack = Chain.current().terse;
      _lock = Completer();
      return Future.value();
    }
  } else {
    return () async {
      while (isHeld) {
        await _lock!.future;
      }
      _lock = Completer();
    }();
  }
}