66 lines
2.4 KiB
Java
66 lines
2.4 KiB
Java
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);
|
|
public static final int b;
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public static final AtomicReference<s>[] f2863c;
|
|
public static final t d = new t();
|
|
|
|
static {
|
|
int highestOneBit = Integer.highestOneBit((Runtime.getRuntime().availableProcessors() * 2) - 1);
|
|
b = highestOneBit;
|
|
AtomicReference<s>[] atomicReferenceArr = new AtomicReference[highestOneBit];
|
|
for (int i = 0; i < highestOneBit; i++) {
|
|
atomicReferenceArr[i] = new AtomicReference<>();
|
|
}
|
|
f2863c = atomicReferenceArr;
|
|
}
|
|
|
|
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()");
|
|
AtomicReference<s> atomicReference = f2863c[(int) (currentThread.getId() & (((long) b) - 1))];
|
|
s sVar2 = atomicReference.get();
|
|
if (sVar2 != a) {
|
|
int i = sVar2 != null ? sVar2.f2862c : 0;
|
|
if (i < 65536) {
|
|
sVar.f = sVar2;
|
|
sVar.b = 0;
|
|
sVar.f2862c = i + 8192;
|
|
if (!atomicReference.compareAndSet(sVar2, sVar)) {
|
|
sVar.f = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public static final s b() {
|
|
Thread currentThread = Thread.currentThread();
|
|
m.checkExpressionValueIsNotNull(currentThread, "Thread.currentThread()");
|
|
AtomicReference<s> atomicReference = f2863c[(int) (currentThread.getId() & (((long) b) - 1))];
|
|
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;
|
|
andSet.f2862c = 0;
|
|
return andSet;
|
|
}
|
|
}
|