dispose method

void dispose()

Releases a live hold as the App tears the debug surface down.

Synchronous like every other dispose here: the release is queued but not awaited, so a slow consumer implementation cannot hold up host teardown. It uses the same queue as operator requests so teardown cannot overlap an in-flight release and call a non-reentrant delegate twice.

Releasing what is held is only half of it. Nothing is held yet during the window between a request arriving and its gate returning, so a dispose landing there has nothing to give back — and the danger is entirely on the other side, in the suspended request that would otherwise resume and engage a host that no longer exists. _disposed is what closes that door; it is set first, before anything can await.

Implementation

void dispose() {
  _disposed = true;
  _cancelLease();
  unawaited(
    _enqueue(() async {
      if (!_enabled) return;
      await _release(PatchbayKeepAwakeReleaseWire.hostDisposed);
    }),
  );
}