discord-jadx/app/src/main/java/g0/t.java

66 lines
2.3 KiB
Java
Raw Normal View History

2021-11-02 06:38:17 +00:00
package g0;
import d0.z.d.m;
import java.util.concurrent.atomic.AtomicReference;
/* compiled from: SegmentPool.kt */
public final class t {
public static final s a = new s(new byte[0], 0, 0, false, false);
2021-12-17 21:59:34 +00:00
/* renamed from: b reason: collision with root package name */
2022-02-10 02:59:54 +00:00
public static final int f3668b;
2021-12-17 21:59:34 +00:00
public static final AtomicReference<s>[] c;
2021-11-02 06:38:17 +00:00
public static final t d = new t();
static {
int highestOneBit = Integer.highestOneBit((Runtime.getRuntime().availableProcessors() * 2) - 1);
2022-02-10 02:59:54 +00:00
f3668b = highestOneBit;
2021-11-02 06:38:17 +00:00
AtomicReference<s>[] atomicReferenceArr = new AtomicReference[highestOneBit];
for (int i = 0; i < highestOneBit; i++) {
atomicReferenceArr[i] = new AtomicReference<>();
}
2021-12-17 21:59:34 +00:00
c = atomicReferenceArr;
2021-11-02 06:38:17 +00:00
}
public static final void a(s sVar) {
m.checkParameterIsNotNull(sVar, "segment");
if (!(sVar.f == null && sVar.g == null)) {
throw new IllegalArgumentException("Failed requirement.".toString());
} else if (!sVar.d) {
Thread currentThread = Thread.currentThread();
m.checkExpressionValueIsNotNull(currentThread, "Thread.currentThread()");
2022-02-10 02:59:54 +00:00
AtomicReference<s> atomicReference = c[(int) (currentThread.getId() & (((long) f3668b) - 1))];
2021-11-02 06:38:17 +00:00
s sVar2 = atomicReference.get();
if (sVar2 != a) {
2021-12-17 21:59:34 +00:00
int i = sVar2 != null ? sVar2.c : 0;
2021-11-02 06:38:17 +00:00
if (i < 65536) {
sVar.f = sVar2;
2022-02-10 02:59:54 +00:00
sVar.f3667b = 0;
2021-12-17 21:59:34 +00:00
sVar.c = i + 8192;
2021-11-02 06:38:17 +00:00
if (!atomicReference.compareAndSet(sVar2, sVar)) {
sVar.f = null;
}
}
}
}
}
public static final s b() {
Thread currentThread = Thread.currentThread();
m.checkExpressionValueIsNotNull(currentThread, "Thread.currentThread()");
2022-02-10 02:59:54 +00:00
AtomicReference<s> atomicReference = c[(int) (currentThread.getId() & (((long) f3668b) - 1))];
2021-11-02 06:38:17 +00:00
s sVar = a;
s andSet = atomicReference.getAndSet(sVar);
if (andSet == sVar) {
return new s();
}
if (andSet == null) {
atomicReference.set(null);
return new s();
}
atomicReference.set(andSet.f);
andSet.f = null;
2021-12-17 21:59:34 +00:00
andSet.c = 0;
2021-11-02 06:38:17 +00:00
return andSet;
}
}