Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,18 @@ public static void waitForInput(Supplier<Boolean> liveCheck, InputStream inputSt
String workerDeathMsg = "Worker process for died while waiting for response";
// TODO can we do better than spinning? i.e. condition variable?
while (inputAvailable(inputStream, workerDeathMsg) == 0) {
Thread.sleep(10);
try {
Thread.sleep(10);
} catch (InterruptedException e) {
if (inputAvailable(inputStream, workerDeathMsg) > 0) {
// we were interrupted because the task is complete and we're still spinning: if there's a work response
// available, read it and ignore the interrupt
Thread.currentThread().interrupt();
return;
} else {
throw e;
}
}
if (!liveCheck.get()) {
throw new IOException(workerDeathMsg + "\n");
}
Expand Down