what-the-bank/sources/com/facetec/sdk/jp.java

128 lines
3.9 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package com.facetec.sdk;
import com.facetec.sdk.ky;
import java.lang.ref.Reference;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.List;
import java.util.concurrent.Executor;
import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
/* loaded from: classes.dex */
public final class jp {
static final Executor b = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60, TimeUnit.SECONDS, new SynchronousQueue(), km.d("OkHttp ConnectionPool", true));
static final boolean h = true;
boolean a;
final Runnable c;
final kv d;
final Deque<kt> e;
private final int g;
private final long i;
public jp() {
this(TimeUnit.MINUTES);
}
private jp(TimeUnit timeUnit) {
this.c = new Runnable(this) { // from class: com.facetec.sdk.jp.4
private jp c;
{
this.c = this;
}
@Override // java.lang.Runnable
public final void run() {
while (true) {
long e = this.c.e(System.nanoTime());
if (e == -1) {
return;
}
if (e > 0) {
long j = e / 1000000;
synchronized (this.c) {
try {
this.c.wait(j, (int) (e - (1000000 * j)));
} catch (InterruptedException unused) {
}
}
}
}
}
};
this.e = new ArrayDeque();
this.d = new kv();
this.g = 5;
this.i = timeUnit.toNanos(5L);
}
/* JADX INFO: Access modifiers changed from: package-private */
public final boolean a(kt ktVar) {
if (!h && !Thread.holdsLock(this)) {
throw new AssertionError();
}
if (ktVar.i || this.g == 0) {
this.e.remove(ktVar);
return true;
}
notifyAll();
return false;
}
final long e(long j) {
synchronized (this) {
kt ktVar = null;
long j2 = Long.MIN_VALUE;
int i = 0;
int i2 = 0;
for (kt ktVar2 : this.e) {
List<Reference<ky>> list = ktVar2.f6451o;
int i3 = 0;
while (true) {
if (i3 < list.size()) {
Reference<ky> reference = list.get(i3);
if (reference.get() == null) {
StringBuilder sb = new StringBuilder("A connection to ");
sb.append(ktVar2.c().e().b());
sb.append(" was leaked. Did you forget to close a response body?");
mi.c().c(sb.toString(), ((ky.e) reference).c);
list.remove(i3);
ktVar2.i = true;
if (list.isEmpty()) {
ktVar2.k = j - this.i;
break;
}
} else {
i3++;
}
} else if (list.size() > 0) {
i2++;
}
}
i++;
long j3 = j - ktVar2.k;
if (j3 > j2) {
ktVar = ktVar2;
j2 = j3;
}
}
long j4 = this.i;
if (j2 >= j4 || i > this.g) {
this.e.remove(ktVar);
km.b(ktVar.d());
return 0L;
}
if (i > 0) {
return j4 - j2;
}
if (i2 > 0) {
return j4;
}
this.a = false;
return -1L;
}
}
}