runOnceAsyncWithTimeout method
Creates a timed isolate for a single inference run. Each call creates a fresh isolate, allowing concurrent inference. The isolate will timeout after the specified duration. The isolate is automatically killed after completion or timeout.
Implementation
Future<List<OrtValue?>> runOnceAsyncWithTimeout(
OrtRunOptions runOptions, Map<String, OrtValue> inputs,
Duration timeout,
[List<String>? outputNames]) async {
// Create a new isolate session with custom timeout
// This allows multiple concurrent timed inferences
final isolateSession = OrtIsolateSession(this, timeout: timeout);
_activeIsolateSessions.add(isolateSession);
try {
final result = await isolateSession.run(runOptions, inputs, outputNames);
return result;
} finally {
// Always clean up the isolate after use
await isolateSession.release();
_activeIsolateSessions.remove(isolateSession);
}
}