in safeguard-impl/src/main/java/org/apache/safeguard/impl/asynchronous/BaseAsynchronousInterceptor.java [187:204]
public T get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
final long latchWaitStart = System.nanoTime();
final boolean latchWait = latch.await(timeout, unit);
final long latchWaitDuration = System.nanoTime() - latchWaitStart;
if (!latchWait) {
throw new TimeoutException();
}
try {
return delegate.get().get(unit.toNanos(timeout) - latchWaitDuration, NANOSECONDS);
} catch (final ExecutionException ee) {
delegate.set(onException(ee));
final long duration = unit.toNanos(timeout) - (System.nanoTime() - latchWaitDuration);
if (duration < 0) {
throw new TimeoutException();
}
return delegate.get().get(duration, NANOSECONDS);
}
}