Skip to content

Commit

Permalink
Change how min wait time is computed
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrr888 committed Jan 4, 2024
1 parent 1b885d8 commit c98f70d
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,10 @@ public long reserve() {
if (deferred.isEmpty()) {
this.wait(5000);
} else {
Long minTime = Collections.min(deferred.values());
long waitTime = minTime - System.nanoTime();
waitTime = TimeUnit.MILLISECONDS.convert(waitTime, TimeUnit.NANOSECONDS);
long currTime = System.nanoTime();
long minWait =
deferred.values().stream().mapToLong(l -> l - currTime).min().getAsLong();
long waitTime = TimeUnit.MILLISECONDS.convert(minWait, TimeUnit.NANOSECONDS);
if (waitTime > 0) {
this.wait(Math.min(waitTime, 5000));
}
Expand Down

0 comments on commit c98f70d

Please sign in to comment.