restart method
void
restart(
- void callback()
Powers down the executor and isolate and then powers up another one and invokes the callback once that replacement executor is awake.
Throws an exception if _numRetries
== maxRetries.
Do not call dispose in this method, as that will close the response controller which we must reuse, because whoever originally called generateResponse already has its stream and is waiting for a response.
Implementation
void restart(void Function() callback) {
_log.shout('RESTARTING INFERENCE EXECUTOR - REACHED TIMEOUT OF '
'${timeout.inSeconds} seconds');
_sendPort.send(null);
if (_numRetries == maxRetries) {
throw Exception('Reached retry limit of $maxRetries.');
}
_numRetries++;
if (!_readyCompleter.isCompleted) {
_readyCompleter.complete(false);
}
_readyCompleter = Completer<bool>();
_initializeIsolate().then(
(bool success) {
if (!success) {
_log.shout('Failed to initialize isolate during restart');
return;
}
callback();
},
);
}