Skip to content

Commit

Permalink
Merge pull request #219 from petrkaderabek/completer
Browse files Browse the repository at this point in the history
Handle SendPort initialization
  • Loading branch information
PaulTR committed Jun 18, 2024
2 parents 6b91140 + 42311ec commit 12be124
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/src/isolate_interpreter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,20 @@ class IsolateInterpreter {
_receivePort.sendPort,
debugName: debugName,
);
final Completer<SendPort> sendPortCompleter = Completer<SendPort>();

_stateSubscription = _receivePort.listen((state) {
if (state is SendPort) {
_sendPort = state;
sendPortCompleter.complete(_sendPort);
}

if (state is IsolateInterpreterState) {
_state = state;
}
});

await sendPortCompleter.future;
}

// Main function for the spawned isolate.
Expand Down

0 comments on commit 12be124

Please sign in to comment.