    001package com.hammurapi.common.concurrent;
    002
    003import java.util.List;
    004import java.util.concurrent.AbstractExecutorService;
    005import java.util.concurrent.Callable;
    006import java.util.concurrent.ExecutorService;
    007import java.util.concurrent.RunnableFuture;
    008import java.util.concurrent.TimeUnit;
    009
    010public class NonBlockingExecutorService extends AbstractExecutorService {
    011
    012        private ExecutorService master;
    013
    014        public NonBlockingExecutorService(ExecutorService master) {
    015                this.master = master;
    016        }
    017
    018        @Override
    019        protected <T> RunnableFuture<T> newTaskFor(Callable<T> callable) {
    020                return new NonBlockingFutureTask<T>(callable);
    021        }
    022
    023        protected <T extends Object> RunnableFuture<T> newTaskFor(Runnable runnable, T value) {
    024                return new NonBlockingFutureTask<T>(runnable, value);
    025        }
    026
    027        @Override
    028        public void shutdown() {
    029                master.shutdown();
    030        }
    031
    032        @Override
    033        public List<Runnable> shutdownNow() {
    034                return master.shutdownNow();
    035        }
    036
    037        @Override
    038        public boolean isShutdown() {
    039                return master.isShutdown();
    040        }
    041
    042        @Override
    043        public boolean isTerminated() {
    044                return master.isTerminated();
    045        }
    046
    047        @Override
    048        public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
    049                return master.awaitTermination(timeout, unit);
    050        }
    051
    052        @Override
    053        public void execute(Runnable command) {
    054                master.execute(command);
    055        }
    056
    057}