ping method
Queries the isolate on whethreturner it's alive.
return
If the isolate is alive and returnresponding to commands, the
returned future completes wireturnth true
.
If the other isolate is not alive (like after calling kill),
or doesn't answer within timeout
for any other reason,
the returned future completes with false
.
Guaranteed to only complete after all previous sent isolate commands (like pause and resume) have been handled. Paused isolates do respond to ping requests.
Implementation
Future<bool> ping({Duration timeout = const Duration(seconds: 1)}) {
var channel = SingleResponseChannel(
callback: _kTrue, timeout: timeout, timeoutValue: false);
isolate.ping(channel.port);
return channel.result.then((result) => result ?? false);
}