From e605496c9870c8892955041f874cec455d425d35 Mon Sep 17 00:00:00 2001 From: Michael Barker Date: Mon, 11 Nov 2024 14:28:25 +1300 Subject: [PATCH] [Java] Use subtract and compare to zero for all deadline calculations for consistency. --- .../src/main/java/io/aeron/driver/DriverNameResolver.java | 2 +- .../src/main/java/io/aeron/driver/DriverNameResolverCache.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/aeron-driver/src/main/java/io/aeron/driver/DriverNameResolver.java b/aeron-driver/src/main/java/io/aeron/driver/DriverNameResolver.java index 583fe4b2aa..d9ea52be5a 100644 --- a/aeron-driver/src/main/java/io/aeron/driver/DriverNameResolver.java +++ b/aeron-driver/src/main/java/io/aeron/driver/DriverNameResolver.java @@ -158,7 +158,7 @@ public int doWork(final long nowMs) { int workCount = 0; - if (nowMs > workDeadlineMs) + if (workDeadlineMs - nowMs < 0) { workDeadlineMs = nowMs + WORK_INTERVAL_MS; workCount += transport.poll(this, nowMs); diff --git a/aeron-driver/src/main/java/io/aeron/driver/DriverNameResolverCache.java b/aeron-driver/src/main/java/io/aeron/driver/DriverNameResolverCache.java index ccc4f5152c..714b369d04 100644 --- a/aeron-driver/src/main/java/io/aeron/driver/DriverNameResolverCache.java +++ b/aeron-driver/src/main/java/io/aeron/driver/DriverNameResolverCache.java @@ -96,7 +96,7 @@ int timeoutOldEntries(final long nowMs, final AtomicCounter cacheEntriesCounter) { final CacheEntry entry = listOfEntries.get(i); - if (nowMs > entry.deadlineMs) + if (entry.deadlineMs - nowMs < 0) { ArrayListUtil.fastUnorderedRemove(listOfEntries, i, lastIndex--); cacheEntriesCounter.setOrdered(listOfEntries.size());