end -> endNanoTime

This commit is contained in:
Benjamin Peterson 2025-07-24 08:39:42 -07:00
parent 8a4181cd9a
commit 17c41c967d
1 changed files with 8 additions and 8 deletions

View File

@ -106,14 +106,14 @@ public final class BlockingClientCall<ReqT, RespT> {
*/ */
public RespT read(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException, public RespT read(long timeout, TimeUnit unit) throws InterruptedException, TimeoutException,
StatusException { StatusException {
long end = System.nanoTime() + unit.toNanos(timeout); long endNanoTime = System.nanoTime() + unit.toNanos(timeout);
return read(false, end); return read(false, endNanoTime);
} }
private RespT read(boolean waitForever, long end) private RespT read(boolean waitForever, long endNanoTime)
throws InterruptedException, TimeoutException, StatusException { throws InterruptedException, TimeoutException, StatusException {
Predicate<BlockingClientCall<ReqT, RespT>> predicate = BlockingClientCall::skipWaitingForRead; Predicate<BlockingClientCall<ReqT, RespT>> predicate = BlockingClientCall::skipWaitingForRead;
executor.waitAndDrainWithTimeout(waitForever, end, predicate, this); executor.waitAndDrainWithTimeout(waitForever, endNanoTime, predicate, this);
RespT bufferedValue = buffer.poll(); RespT bufferedValue = buffer.poll();
if (logger.isLoggable(Level.FINER)) { if (logger.isLoggable(Level.FINER)) {
@ -209,11 +209,11 @@ public final class BlockingClientCall<ReqT, RespT> {
*/ */
public boolean write(ReqT request, long timeout, TimeUnit unit) public boolean write(ReqT request, long timeout, TimeUnit unit)
throws InterruptedException, TimeoutException, StatusException { throws InterruptedException, TimeoutException, StatusException {
long end = System.nanoTime() + unit.toNanos(timeout); long endNanoTime = System.nanoTime() + unit.toNanos(timeout);
return write(false, request, end); return write(false, request, endNanoTime);
} }
private boolean write(boolean waitForever, ReqT request, long end) private boolean write(boolean waitForever, ReqT request, long endNanoTime)
throws InterruptedException, TimeoutException, StatusException { throws InterruptedException, TimeoutException, StatusException {
if (writeClosed) { if (writeClosed) {
@ -222,7 +222,7 @@ public final class BlockingClientCall<ReqT, RespT> {
Predicate<BlockingClientCall<ReqT, RespT>> predicate = Predicate<BlockingClientCall<ReqT, RespT>> predicate =
(x) -> x.call.isReady() || x.closedStatus != null; (x) -> x.call.isReady() || x.closedStatus != null;
executor.waitAndDrainWithTimeout(waitForever, end, predicate, this); executor.waitAndDrainWithTimeout(waitForever, endNanoTime, predicate, this);
Status savedClosedStatus = closedStatus; Status savedClosedStatus = closedStatus;
if (savedClosedStatus == null) { if (savedClosedStatus == null) {
call.sendMessage(request); call.sendMessage(request);