use of com.hazelcast.spi.annotation.PrivateApi in project hazelcast by hazelcast.
the class FutureUtil method waitWithDeadline.
@PrivateApi
public static void waitWithDeadline(Collection<Future> futures, long overallTimeout, TimeUnit overallTimeUnit, long perFutureTimeout, TimeUnit perFutureTimeUnit, ExceptionHandler exceptionHandler) {
// Calculate timeouts for whole operation and per future. If corresponding TimeUnits not set assume
// the default of TimeUnit.SECONDS
long overallTimeoutNanos = calculateTimeout(overallTimeout, overallTimeUnit);
long perFutureTimeoutNanos = calculateTimeout(perFutureTimeout, perFutureTimeUnit);
// Common deadline for all futures
long deadline = System.nanoTime() + overallTimeoutNanos;
for (Future future : futures) {
try {
long timeoutNanos = calculateFutureTimeout(perFutureTimeoutNanos, deadline);
executeWithDeadline(future, timeoutNanos);
} catch (Throwable e) {
exceptionHandler.handleException(e);
}
}
}
Aggregations