org.atmosphere.util.VoidExecutorService Maven / Gradle / Ivy
/*
* Copyright 2008-2024 Async-IO.org
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.atmosphere.util;
import java.util.Collection;
import java.util.List;
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;
/**
* An {@link ExecutorService} that does nothing and execute using the calling Thread.
*/
public class VoidExecutorService implements ExecutorService {
public final static VoidExecutorService VOID = new VoidExecutorService();
@Override
public void shutdown() {
}
@Override
public List shutdownNow() {
return null;
}
@Override
public boolean isShutdown() {
return false;
}
@Override
public boolean isTerminated() {
return false;
}
@Override
public boolean awaitTermination(long l, TimeUnit timeUnit) throws InterruptedException {
return false;
}
@Override
public Future submit(Callable tCallable) {
try {
tCallable.call();
} catch (Exception e) {
}
return null;
}
@Override
public Future submit(Runnable runnable, T t) {
runnable.run();
return null;
}
@Override
public Future> submit(Runnable runnable) {
runnable.run();
return null;
}
@Override
public List> invokeAll(Collection extends Callable> callables) throws InterruptedException {
throw new UnsupportedOperationException();
}
@Override
public List> invokeAll(Collection extends Callable> callables, long l, TimeUnit timeUnit) throws InterruptedException {
throw new UnsupportedOperationException();
}
@Override
public T invokeAny(Collection extends Callable> callables) throws InterruptedException, ExecutionException {
throw new UnsupportedOperationException();
}
@Override
public T invokeAny(Collection extends Callable> callables, long l, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException {
throw new UnsupportedOperationException();
}
@Override
public void execute(Runnable runnable) {
runnable.run();
}
}