Skip to content

Commit

Permalink
Use a monotonic clock for checking timeout on shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Palmr committed Sep 29, 2023
1 parent 8192ba7 commit 95c705f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/lmax/disruptor/dsl/Disruptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -404,10 +404,10 @@ public void shutdown()
*/
public void shutdown(final long timeout, final TimeUnit timeUnit) throws TimeoutException
{
final long timeOutAt = System.currentTimeMillis() + timeUnit.toMillis(timeout);
final long timeOutAt = System.nanoTime() + timeUnit.toNanos(timeout);
while (hasBacklog())
{
if (timeout >= 0 && System.currentTimeMillis() > timeOutAt)
if (timeout >= 0 && System.nanoTime() > timeOutAt)
{
throw TimeoutException.INSTANCE;
}
Expand Down

0 comments on commit 95c705f

Please sign in to comment.