what-the-bank/sources/o/iOx.java

81 lines
2.5 KiB
Java

package o;
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/* loaded from: classes.dex */
final class iOx {
final Map<String, Sts> d = new HashMap();
final HBt a = new HBt();
/* JADX INFO: Access modifiers changed from: package-private */
public final void b(String str) {
Sts sts;
synchronized (this) {
Sts sts2 = this.d.get(str);
if (sts2 != null) {
sts = sts2;
if (sts.d <= 0) {
StringBuilder sb = new StringBuilder("Cannot release a lock that is not held, safeKey: ");
sb.append(str);
sb.append(", interestedThreads: ");
sb.append(sts.d);
throw new IllegalStateException(sb.toString());
}
sts.d--;
if (sts.d == 0) {
Sts remove = this.d.remove(str);
if (!remove.equals(sts)) {
StringBuilder sb2 = new StringBuilder("Removed the wrong lock, expected to remove: ");
sb2.append(sts);
sb2.append(", but actually removed: ");
sb2.append(remove);
sb2.append(", safeKey: ");
sb2.append(str);
throw new IllegalStateException(sb2.toString());
}
HBt hBt = this.a;
synchronized (hBt.b) {
if (hBt.b.size() < 10) {
hBt.b.offer(remove);
}
}
}
} else {
throw new NullPointerException("Argument must not be null");
}
}
sts.a.unlock();
}
/* loaded from: classes.dex */
static class Sts {
final Lock a = new ReentrantLock();
int d;
Sts() {
}
}
/* loaded from: classes.dex */
static class HBt {
final Queue<Sts> b = new ArrayDeque();
HBt() {
}
/* JADX INFO: Access modifiers changed from: package-private */
public final Sts d() {
Sts poll;
synchronized (this.b) {
poll = this.b.poll();
}
return poll == null ? new Sts() : poll;
}
}
}