correct time base for await updates

This commit is contained in:
Jonathan Shook 2020-08-06 13:03:56 -05:00
parent 625be1db16
commit 2d39aad2b1

View File

@ -92,14 +92,14 @@ public class ScenariosExecutor {
boolean isShutdown = false;
while (!isShutdown && System.currentTimeMillis() < timeoutAt) {
long updateAt = Math.min(timeoutAt, System.currentTimeMillis() + updateInterval);
long waitedAt = System.currentTimeMillis();
long updateAt = Math.min(timeoutAt, waitedAt + updateInterval);
while (!isShutdown && System.currentTimeMillis() < timeoutAt) {
while (!isShutdown && System.currentTimeMillis() < updateAt) {
try {
long timeRemaining = timeoutAt - System.currentTimeMillis();
isShutdown = executor.awaitTermination(timeRemaining, TimeUnit.MICROSECONDS);
long timeRemaining = updateAt - System.currentTimeMillis();
isShutdown = executor.awaitTermination(timeRemaining, TimeUnit.MILLISECONDS);
} catch (InterruptedException ignored) {
}
}