destroy method

Future<void> destroy()

Destroys this session.

Implementation

Future<void> destroy() {
  if (_destroyed) return Future<void>.value();
  final inFlight = _destroyFuture;
  if (inFlight != null) return inFlight;
  // Assign _destroyFuture atomically before any async work begins so that
  // a second synchronous caller sees a non-null future immediately.
  final completer = Completer<void>();
  _destroyFuture = completer.future;
  _destroyImpl().then(
    (_) => completer.complete(),
    onError: completer.completeError,
  );
  return completer.future;
}