org.jtrim2.executor.UnstoppableExecutor Maven / Gradle / Ivy
package org.jtrim2.executor;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
/**
* @see ExecutorsEx#asUnstoppableExecutor(java.util.concurrent.ExecutorService)
*/
final class UnstoppableExecutor implements ExecutorService {
private final ExecutorService executor;
public UnstoppableExecutor(ExecutorService executor) {
Objects.requireNonNull(executor, "executor");
this.executor = executor;
}
@Override
public void execute(Runnable command) {
executor.execute(command);
}
@Override
public Future> submit(Runnable task) {
return executor.submit(task);
}
@Override
public Future submit(Runnable task, T result) {
return executor.submit(task, result);
}
@Override
public Future submit(Callable task) {
return executor.submit(task);
}
@Override
public List shutdownNow() {
throw new UnsupportedOperationException(
"This executor cannot be shutted down.");
}
@Override
public void shutdown() {
throw new UnsupportedOperationException(
"This executor cannot be shutted down.");
}
@Override
public boolean isTerminated() {
return executor.isTerminated();
}
@Override
public boolean isShutdown() {
return executor.isShutdown();
}
@Override
public T invokeAny(
Collection extends Callable> tasks,
long timeout,
TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
return executor.invokeAny(tasks, timeout, unit);
}
@Override
public T invokeAny(Collection extends Callable> tasks)
throws InterruptedException, ExecutionException {
return executor.invokeAny(tasks);
}
@Override
public List> invokeAll(
Collection extends Callable> tasks,
long timeout,
TimeUnit unit)
throws InterruptedException {
return executor.invokeAll(tasks, timeout, unit);
}
@Override
public List> invokeAll(
Collection extends Callable> tasks)
throws InterruptedException {
return executor.invokeAll(tasks);
}
@Override
public boolean awaitTermination(long timeout, TimeUnit unit)
throws InterruptedException {
return executor.awaitTermination(timeout, unit);
}
@Override
public String toString() {
return "UnstoppableExecutor{" + executor + '}';
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy