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 */
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes3.dex */
|
2021-11-02 06:38:17 +00:00
|
|
|
public final class t {
|
|
|
|
|
2021-12-17 21:59:34 +00:00
|
|
|
/* renamed from: b reason: collision with root package name */
|
2022-03-28 08:10:50 +00:00
|
|
|
public static final int f3687b;
|
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();
|
2022-03-07 09:34:54 +00:00
|
|
|
public static final s a = new s(new byte[0], 0, 0, false, false);
|
2021-11-02 06:38:17 +00:00
|
|
|
|
|
|
|
static {
|
|
|
|
int highestOneBit = Integer.highestOneBit((Runtime.getRuntime().availableProcessors() * 2) - 1);
|
2022-03-28 08:10:50 +00:00
|
|
|
f3687b = 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-03-28 08:10:50 +00:00
|
|
|
AtomicReference<s> atomicReference = c[(int) (currentThread.getId() & (f3687b - 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-03-28 08:10:50 +00:00
|
|
|
sVar.f3686b = 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-03-28 08:10:50 +00:00
|
|
|
AtomicReference<s> atomicReference = c[(int) (currentThread.getId() & (f3687b - 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;
|
|
|
|
}
|
|
|
|
}
|