viewPeer<T> method

  1. @override
Future<T> viewPeer<T>(
  1. PeerId peer,
  2. Future<T> f(
    1. PeerScope scope
    )
)
override

ViewPeer views the resource management scope for a specific peer.

Implementation

@override
Future<T> viewPeer<T>(PeerId peer, Future<T> Function(PeerScope scope) f) async {
  // Assuming PeerId can be used where PeerId is expected
  final scope = getPeerScopeInternal(peer);
  // Hold the scope while [f] runs, so that gc() does not drop it.
  scope.incRef();
  try {
    return await f(scope);
  } finally {
    scope.decRef();
  }
}