runAsyncWithTimeout method
Performs inference asynchronously with a custom timeout. Uses a persistent isolate that stays alive for reuse. If the isolate times out, it will be killed and recreated on next use.
Implementation
Future<List<OrtValue?>>? runAsyncWithTimeout(
OrtRunOptions runOptions, Map<String, OrtValue> inputs,
Duration timeout,
[List<String>? outputNames]) {
// Create or recreate persistent isolate session with custom timeout
// Note: If timeout changes, we should recreate the isolate session
if (_persistentIsolateSession == null ||
_persistentIsolateSession!.timeout != timeout) {
// Kill existing isolate if timeout has changed
_persistentIsolateSession?.release();
_persistentIsolateSession = OrtIsolateSession(this, timeout: timeout);
}
return _persistentIsolateSession?.run(runOptions, inputs, outputNames);
}