72 lines
2.0 KiB
Java
72 lines
2.0 KiB
Java
|
package o;
|
||
|
|
||
|
import java.util.concurrent.atomic.AtomicLong;
|
||
|
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||
|
|
||
|
/* renamed from: o.fZr, reason: case insensitive filesystem */
|
||
|
/* loaded from: classes6.dex */
|
||
|
public final class C13415fZr<E> extends AtomicReferenceArray<E> implements InterfaceC13408fZk<E> {
|
||
|
private static final Integer b = Integer.getInteger("jctools.spsc.max.lookahead.step", 4096);
|
||
|
private AtomicLong a;
|
||
|
private int c;
|
||
|
private AtomicLong d;
|
||
|
private int e;
|
||
|
private long i;
|
||
|
|
||
|
@Override // o.InterfaceC13414fZq
|
||
|
public final boolean b(E e) {
|
||
|
if (e == null) {
|
||
|
throw new NullPointerException("Null is not a valid element");
|
||
|
}
|
||
|
int i = this.e;
|
||
|
long j = this.a.get();
|
||
|
int i2 = ((int) j) & i;
|
||
|
if (j >= this.i) {
|
||
|
long j2 = this.c + j;
|
||
|
if (get(i & ((int) j2)) == null) {
|
||
|
this.i = j2;
|
||
|
} else if (get(i2) != null) {
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
lazySet(i2, e);
|
||
|
this.a.lazySet(j + 1);
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
@Override // o.InterfaceC13408fZk, o.InterfaceC13414fZq
|
||
|
public final E b() {
|
||
|
long j = this.d.get();
|
||
|
int i = ((int) j) & this.e;
|
||
|
E e = get(i);
|
||
|
if (e == null) {
|
||
|
return null;
|
||
|
}
|
||
|
this.d.lazySet(j + 1);
|
||
|
lazySet(i, null);
|
||
|
return e;
|
||
|
}
|
||
|
|
||
|
@Override // o.InterfaceC13414fZq
|
||
|
public final boolean c() {
|
||
|
return this.a.get() == this.d.get();
|
||
|
}
|
||
|
|
||
|
@Override // o.InterfaceC13414fZq
|
||
|
public final void e() {
|
||
|
while (true) {
|
||
|
if (b() == null && this.a.get() == this.d.get()) {
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public C13415fZr(int i) {
|
||
|
super(1 << (32 - Integer.numberOfLeadingZeros(i - 1)));
|
||
|
this.e = length() - 1;
|
||
|
this.a = new AtomicLong();
|
||
|
this.d = new AtomicLong();
|
||
|
this.c = Math.min(i / 4, b.intValue());
|
||
|
}
|
||
|
}
|