waitForMaintenance method

Future<void> waitForMaintenance()

Waits for any in-flight background segment build.

Rethrows a build error, if one was recorded.

Implementation

Future<void> waitForMaintenance() async {
  while (_backgroundFuture != null || _maintenanceScheduled) {
    final future = _backgroundFuture;
    if (future != null) {
      await future;
    } else {
      await Future<void>.delayed(Duration.zero);
    }
  }
  final error = _backgroundError;
  if (error != null) {
    _backgroundError = null;
    Error.throwWithStackTrace(error, _backgroundStack!);
  }
}