Search in sources :

Example 1 with ExecutorServiceAdapter

use of io.airlift.concurrent.ExecutorServiceAdapter in project presto by prestodb.

the class TimeoutBackupStore method timeLimited.

private static <T> T timeLimited(T target, Class<T> clazz, Duration timeout, ExecutorService executor, int maxThreads) {
    executor = new ExecutorServiceAdapter(new BoundedExecutor(executor, maxThreads));
    TimeLimiter limiter = new SimpleTimeLimiter(executor);
    return limiter.newProxy(target, clazz, timeout.toMillis(), MILLISECONDS);
}
Also used : SimpleTimeLimiter(com.google.common.util.concurrent.SimpleTimeLimiter) TimeLimiter(com.google.common.util.concurrent.TimeLimiter) ExecutorServiceAdapter(io.airlift.concurrent.ExecutorServiceAdapter) SimpleTimeLimiter(com.google.common.util.concurrent.SimpleTimeLimiter) BoundedExecutor(io.airlift.concurrent.BoundedExecutor)

Aggregations

SimpleTimeLimiter (com.google.common.util.concurrent.SimpleTimeLimiter)1 TimeLimiter (com.google.common.util.concurrent.TimeLimiter)1 BoundedExecutor (io.airlift.concurrent.BoundedExecutor)1 ExecutorServiceAdapter (io.airlift.concurrent.ExecutorServiceAdapter)1