Search in sources :

Example 1 with PrivateApi

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);
        }
    }
}
Also used : InternalCompletableFuture(com.hazelcast.spi.InternalCompletableFuture) Future(java.util.concurrent.Future) PrivateApi(com.hazelcast.spi.annotation.PrivateApi)

Aggregations

InternalCompletableFuture (com.hazelcast.spi.InternalCompletableFuture)1 PrivateApi (com.hazelcast.spi.annotation.PrivateApi)1 Future (java.util.concurrent.Future)1