125 lines
3.6 KiB
Java
125 lines
3.6 KiB
Java
package com.facetec.sdk;
|
|
|
|
import com.facetec.sdk.kg;
|
|
import java.io.InterruptedIOException;
|
|
import java.util.ArrayDeque;
|
|
import java.util.ArrayList;
|
|
import java.util.Deque;
|
|
import java.util.Iterator;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.RejectedExecutionException;
|
|
import java.util.concurrent.SynchronousQueue;
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class jr {
|
|
private static boolean h = true;
|
|
private Runnable b;
|
|
private ExecutorService c;
|
|
public int e = 64;
|
|
private int d = 5;
|
|
final Deque<kg.a> a = new ArrayDeque();
|
|
private final Deque<kg.a> g = new ArrayDeque();
|
|
private final Deque<kg> j = new ArrayDeque();
|
|
|
|
private ExecutorService d() {
|
|
ExecutorService executorService;
|
|
synchronized (this) {
|
|
if (this.c == null) {
|
|
this.c = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue(), km.d("OkHttp Dispatcher", false));
|
|
}
|
|
executorService = this.c;
|
|
}
|
|
return executorService;
|
|
}
|
|
|
|
public final boolean b() {
|
|
int i;
|
|
boolean z;
|
|
if (!h && Thread.holdsLock(this)) {
|
|
throw new AssertionError();
|
|
}
|
|
ArrayList arrayList = new ArrayList();
|
|
synchronized (this) {
|
|
Iterator<kg.a> it = this.a.iterator();
|
|
while (true) {
|
|
i = 0;
|
|
if (!it.hasNext()) {
|
|
break;
|
|
}
|
|
kg.a next = it.next();
|
|
if (this.g.size() >= this.e) {
|
|
break;
|
|
}
|
|
for (kg.a aVar : this.g) {
|
|
if (!aVar.e.f && aVar.b().equals(next.b())) {
|
|
i++;
|
|
}
|
|
}
|
|
if (i < this.d) {
|
|
it.remove();
|
|
arrayList.add(next);
|
|
this.g.add(next);
|
|
}
|
|
}
|
|
z = c() > 0;
|
|
}
|
|
int size = arrayList.size();
|
|
while (i < size) {
|
|
kg.a aVar2 = (kg.a) arrayList.get(i);
|
|
ExecutorService d = d();
|
|
if (!kg.a.c && Thread.holdsLock(aVar2.e.c.l())) {
|
|
throw new AssertionError();
|
|
}
|
|
try {
|
|
try {
|
|
d.execute(aVar2);
|
|
} catch (RejectedExecutionException e) {
|
|
new InterruptedIOException("executor rejected").initCause(e);
|
|
jx unused = aVar2.e.d;
|
|
kg kgVar = aVar2.e;
|
|
jm jmVar = aVar2.a;
|
|
kg kgVar2 = aVar2.e;
|
|
jmVar.e();
|
|
aVar2.e.c.l().b(aVar2);
|
|
}
|
|
i++;
|
|
} catch (Throwable th) {
|
|
aVar2.e.c.l().b(aVar2);
|
|
throw th;
|
|
}
|
|
}
|
|
return z;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public final void b(kg.a aVar) {
|
|
e(this.g, aVar);
|
|
}
|
|
|
|
private <T> void e(Deque<T> deque, T t) {
|
|
Runnable runnable;
|
|
synchronized (this) {
|
|
if (!deque.remove(t)) {
|
|
throw new AssertionError("Call wasn't in-flight!");
|
|
}
|
|
runnable = this.b;
|
|
}
|
|
if (b() || runnable == null) {
|
|
return;
|
|
}
|
|
runnable.run();
|
|
}
|
|
|
|
private int c() {
|
|
int size;
|
|
int size2;
|
|
synchronized (this) {
|
|
size = this.g.size();
|
|
size2 = this.j.size();
|
|
}
|
|
return size + size2;
|
|
}
|
|
}
|