Engine heartbeat drive interface. Blocks the current thread and pumps asynchronous computation tasks. It is the sole bridge connecting "task submission" and "result callbacks."
int LiteRtLm_WaitUntilDone(void* engine_ptr, int timeout_sec);
| Param/Return | Description |
|---|---|
engine_ptr |
Handle to the engine instance to drive. |
timeout_sec |
Timeout for a single blocking call. Set to 0 for default timeout (typically 600 seconds). |
Return Value (int) |
Status Codes: 0: All inference tasks completed normally. 1: Single block timed out, but tasks are still in progress. -1: Fatal internal engine error occurred. |
// Runs in an independent background thread
void UMyAiSubsystem::InferenceWorker() {
while (bIsRunning) {
// Block and wait for token production
int Result = LiteRtLm_WaitUntilDone(EngineHandle, 1);
if (Result == 0) {
// All tasks done, sleep to save CPU
FPlatformProcess::Sleep(0.1f);
} else if (Result < 0) {
UE_LOG(LogTemp, Error, TEXT("Engine Heartbeat Lost!"));
break;
}
// Result == 1 means still generating, continue next loop
}
}