Example usage for com.google.common.util.concurrent ForwardingExecutorService ForwardingExecutorService

List of usage examples for com.google.common.util.concurrent ForwardingExecutorService ForwardingExecutorService

Introduction

In this page you can find the example usage for com.google.common.util.concurrent ForwardingExecutorService ForwardingExecutorService.

Prototype

protected ForwardingExecutorService() 

Source Link

Document

Constructor for use by subclasses.

Usage

From source file:org.apache.bookkeeper.common.util.OrderedExecutor.java

protected ExecutorService addExecutorDecorators(ExecutorService executor) {
    return new ForwardingExecutorService() {
        @Override/*from   w w  w.ja v  a  2 s .  co  m*/
        protected ExecutorService delegate() {
            return executor;
        }

        @Override
        public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks)
                throws InterruptedException {
            return super.invokeAll(timedCallables(tasks));
        }

        @Override
        public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout,
                TimeUnit unit) throws InterruptedException {
            return super.invokeAll(timedCallables(tasks), timeout, unit);
        }

        @Override
        public <T> T invokeAny(Collection<? extends Callable<T>> tasks)
                throws InterruptedException, ExecutionException {
            return super.invokeAny(timedCallables(tasks));
        }

        @Override
        public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)
                throws InterruptedException, ExecutionException, TimeoutException {
            return super.invokeAny(timedCallables(tasks), timeout, unit);
        }

        @Override
        public void execute(Runnable command) {
            super.execute(timedRunnable(command));
        }

        @Override
        public <T> Future<T> submit(Callable<T> task) {
            return super.submit(timedCallable(task));
        }

        @Override
        public Future<?> submit(Runnable task) {
            return super.submit(timedRunnable(task));
        }

        @Override
        public <T> Future<T> submit(Runnable task, T result) {
            return super.submit(timedRunnable(task), result);
        }
    };
}