close method

  1. @override
FutureOr<void> close()
override

Close this Actor.

This method awaits for the underlying Handler to close, but remote errors are not currently propagated to the caller (i.e. even if the Handler throws an error on close, this method will NOT throw).

Notice that when backed by a Dart Isolate, the Isolate will not terminate until the Handler's close method completes, successfully or not.

Implementation

@override
FutureOr<void> close() async {
  if (_isClosed) return;
  _isClosed = true;
  final ack = _answerStream.firstWhere(
      (msg) => msg.content == #actor_terminated,
      orElse: () => const Message(0, null));
  (await _sender).send(TerminateActor.singleton);
  await ack;
  await _actorImpl.close();
}