what-the-bank/sources/com/huawei/hms/framework/common/ExecutorsEnhance.java

108 lines
4.5 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package com.huawei.hms.framework.common;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.AbstractExecutorService;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
/* loaded from: classes2.dex */
public class ExecutorsEnhance {
public static ExecutorService newSingleThreadExecutor(ThreadFactory threadFactory) {
ThreadPoolExcutorEnhance threadPoolExcutorEnhance = new ThreadPoolExcutorEnhance(1, 1, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue(), threadFactory);
threadPoolExcutorEnhance.allowCoreThreadTimeOut(true);
return new FinalizableDelegatedExecutorService(threadPoolExcutorEnhance);
}
/* loaded from: classes2.dex */
static class FinalizableDelegatedExecutorService extends DelegatedExecutorService {
FinalizableDelegatedExecutorService(ExecutorService executorService) {
super(executorService);
}
protected void finalize() {
super.shutdown();
}
}
/* loaded from: classes2.dex */
static class DelegatedExecutorService extends AbstractExecutorService {
private final ExecutorService executorService;
DelegatedExecutorService(ExecutorService executorService) {
this.executorService = executorService;
}
@Override // java.util.concurrent.Executor
public void execute(Runnable runnable) {
this.executorService.execute(runnable);
}
@Override // java.util.concurrent.ExecutorService
public void shutdown() {
this.executorService.shutdown();
}
@Override // java.util.concurrent.ExecutorService
public List<Runnable> shutdownNow() {
return this.executorService.shutdownNow();
}
@Override // java.util.concurrent.ExecutorService
public boolean isShutdown() {
return this.executorService.isShutdown();
}
@Override // java.util.concurrent.ExecutorService
public boolean isTerminated() {
return this.executorService.isTerminated();
}
@Override // java.util.concurrent.AbstractExecutorService, java.util.concurrent.ExecutorService
public <T> Future<T> submit(Runnable runnable, T t) {
return this.executorService.submit(runnable, t);
}
@Override // java.util.concurrent.ExecutorService
public boolean awaitTermination(long j, TimeUnit timeUnit) throws InterruptedException {
return this.executorService.awaitTermination(j, timeUnit);
}
@Override // java.util.concurrent.AbstractExecutorService, java.util.concurrent.ExecutorService
public <T> Future<T> submit(Callable<T> callable) {
return this.executorService.submit(callable);
}
@Override // java.util.concurrent.AbstractExecutorService, java.util.concurrent.ExecutorService
public Future<?> submit(Runnable runnable) {
return this.executorService.submit(runnable);
}
@Override // java.util.concurrent.AbstractExecutorService, java.util.concurrent.ExecutorService
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> collection, long j, TimeUnit timeUnit) throws InterruptedException {
return this.executorService.invokeAll(collection, j, timeUnit);
}
@Override // java.util.concurrent.AbstractExecutorService, java.util.concurrent.ExecutorService
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> collection) throws InterruptedException {
return this.executorService.invokeAll(collection);
}
@Override // java.util.concurrent.AbstractExecutorService, java.util.concurrent.ExecutorService
public <T> T invokeAny(Collection<? extends Callable<T>> collection, long j, TimeUnit timeUnit) throws InterruptedException, ExecutionException, TimeoutException {
return (T) this.executorService.invokeAny(collection, j, timeUnit);
}
@Override // java.util.concurrent.AbstractExecutorService, java.util.concurrent.ExecutorService
public <T> T invokeAny(Collection<? extends Callable<T>> collection) throws InterruptedException, ExecutionException {
return (T) this.executorService.invokeAny(collection);
}
}
}