You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

137 lines
4.3 KiB

package p014e0;
import android.os.Handler;
import android.os.Process;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import p020g0.InterfaceC0731a;
/* renamed from: e0.h */
/* loaded from: classes.dex */
public class C0659h {
/* renamed from: e0.h$a */
/* loaded from: classes.dex */
public static class ThreadFactoryC0660a implements ThreadFactory {
/* renamed from: a */
public String f2201a;
/* renamed from: b */
public int f2202b;
/* renamed from: e0.h$a$a */
/* loaded from: classes.dex */
public static class C0661a extends Thread {
/* renamed from: d */
public final int f2203d;
public C0661a(Runnable runnable, String str, int i) {
super(runnable, str);
this.f2203d = i;
}
@Override // java.lang.Thread, java.lang.Runnable
public void run() {
Process.setThreadPriority(this.f2203d);
super.run();
}
}
public ThreadFactoryC0660a(String str, int i) {
this.f2201a = str;
this.f2202b = i;
}
@Override // java.util.concurrent.ThreadFactory
public Thread newThread(Runnable runnable) {
return new C0661a(runnable, this.f2201a, this.f2202b);
}
}
/* renamed from: e0.h$b */
/* loaded from: classes.dex */
public static class RunnableC0662b<T> implements Runnable {
/* renamed from: d */
public Callable<T> f2204d;
/* renamed from: e */
public InterfaceC0731a<T> f2205e;
/* renamed from: f */
public Handler f2206f;
/* renamed from: e0.h$b$a */
/* loaded from: classes.dex */
public class RunnableC0663a implements Runnable {
/* renamed from: d */
public final /* synthetic */ InterfaceC0731a f2207d;
/* renamed from: e */
public final /* synthetic */ Object f2208e;
public RunnableC0663a(InterfaceC0731a interfaceC0731a, Object obj) {
this.f2207d = interfaceC0731a;
this.f2208e = obj;
}
/* JADX WARN: Multi-variable type inference failed */
@Override // java.lang.Runnable
public void run() {
this.f2207d.accept(this.f2208e);
}
}
public RunnableC0662b(Handler handler, Callable<T> callable, InterfaceC0731a<T> interfaceC0731a) {
this.f2204d = callable;
this.f2205e = interfaceC0731a;
this.f2206f = handler;
}
@Override // java.lang.Runnable
public void run() {
T t;
try {
t = this.f2204d.call();
} catch (Exception unused) {
t = null;
}
this.f2206f.post(new RunnableC0663a(this.f2205e, t));
}
}
/* renamed from: a */
public static ThreadPoolExecutor m3186a(String str, int i, int i2) {
ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(0, 1, i2, TimeUnit.MILLISECONDS, new LinkedBlockingDeque(), new ThreadFactoryC0660a(str, i));
threadPoolExecutor.allowCoreThreadTimeOut(true);
return threadPoolExecutor;
}
/* renamed from: b */
public static <T> void m3185b(Executor executor, Callable<T> callable, InterfaceC0731a<T> interfaceC0731a) {
executor.execute(new RunnableC0662b(C0644b.m3225a(), callable, interfaceC0731a));
}
/* renamed from: c */
public static <T> T m3184c(ExecutorService executorService, Callable<T> callable, int i) {
try {
return executorService.submit(callable).get(i, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
throw e;
} catch (ExecutionException e2) {
throw new RuntimeException(e2);
} catch (TimeoutException unused) {
throw new InterruptedException("timeout");
}
}
}