228 lines
6.8 KiB
Java
228 lines
6.8 KiB
Java
package o;
|
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
/* renamed from: o.fVo, reason: case insensitive filesystem */
|
|
/* loaded from: classes6.dex */
|
|
public final class C13271fVo<T> extends fUX<T, T> implements InterfaceC13174fSv<T> {
|
|
final Sts<T> b;
|
|
final AtomicReference<LWm<T>[]> d;
|
|
private volatile boolean f;
|
|
private AtomicBoolean g;
|
|
private int h;
|
|
private volatile long i;
|
|
private Throwable j;
|
|
private Sts<T> l;
|
|
|
|
/* renamed from: o, reason: collision with root package name */
|
|
private int f9116o;
|
|
static final LWm[] e = new LWm[0];
|
|
private static LWm[] a = new LWm[0];
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onSubscribe(fSJ fsj) {
|
|
}
|
|
|
|
public C13271fVo(AbstractC13163fSk<T> abstractC13163fSk, int i) {
|
|
super(abstractC13163fSk);
|
|
this.h = i;
|
|
this.g = new AtomicBoolean();
|
|
Sts<T> sts = new Sts<>(i);
|
|
this.b = sts;
|
|
this.l = sts;
|
|
this.d = new AtomicReference<>(e);
|
|
}
|
|
|
|
@Override // o.AbstractC13163fSk
|
|
public final void subscribeActual(InterfaceC13174fSv<? super T> interfaceC13174fSv) {
|
|
LWm<T> lWm = new LWm<>(interfaceC13174fSv, this);
|
|
interfaceC13174fSv.onSubscribe(lWm);
|
|
loop0: while (true) {
|
|
LWm<T>[] lWmArr = this.d.get();
|
|
if (lWmArr == a) {
|
|
break;
|
|
}
|
|
int length = lWmArr.length;
|
|
LWm<T>[] lWmArr2 = new LWm[length + 1];
|
|
System.arraycopy(lWmArr, 0, lWmArr2, 0, length);
|
|
lWmArr2[length] = lWm;
|
|
AtomicReference<LWm<T>[]> atomicReference = this.d;
|
|
while (!atomicReference.compareAndSet(lWmArr, lWmArr2)) {
|
|
if (atomicReference.get() != lWmArr) {
|
|
break;
|
|
}
|
|
}
|
|
break loop0;
|
|
}
|
|
if (!this.g.get() && this.g.compareAndSet(false, true)) {
|
|
this.c.subscribe(this);
|
|
} else {
|
|
b(lWm);
|
|
}
|
|
}
|
|
|
|
private void b(LWm<T> lWm) {
|
|
if (lWm.getAndIncrement() != 0) {
|
|
return;
|
|
}
|
|
long j = lWm.a;
|
|
int i = lWm.e;
|
|
Sts<T> sts = lWm.d;
|
|
InterfaceC13174fSv<? super T> interfaceC13174fSv = lWm.c;
|
|
int i2 = this.h;
|
|
int i3 = 1;
|
|
while (!lWm.b) {
|
|
boolean z = this.f;
|
|
boolean z2 = this.i == j;
|
|
if (z && z2) {
|
|
lWm.d = null;
|
|
Throwable th = this.j;
|
|
if (th != null) {
|
|
interfaceC13174fSv.onError(th);
|
|
return;
|
|
} else {
|
|
interfaceC13174fSv.onComplete();
|
|
return;
|
|
}
|
|
}
|
|
if (!z2) {
|
|
if (i == i2) {
|
|
sts = sts.e;
|
|
i = 0;
|
|
}
|
|
interfaceC13174fSv.onNext(sts.b[i]);
|
|
i++;
|
|
j++;
|
|
} else {
|
|
lWm.a = j;
|
|
lWm.e = i;
|
|
lWm.d = sts;
|
|
i3 = lWm.addAndGet(-i3);
|
|
if (i3 == 0) {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
lWm.d = null;
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onNext(T t) {
|
|
int i = this.f9116o;
|
|
if (i == this.h) {
|
|
Sts<T> sts = new Sts<>(i);
|
|
sts.b[0] = t;
|
|
this.f9116o = 1;
|
|
this.l.e = sts;
|
|
this.l = sts;
|
|
} else {
|
|
this.l.b[i] = t;
|
|
this.f9116o = i + 1;
|
|
}
|
|
this.i++;
|
|
for (LWm<T> lWm : this.d.get()) {
|
|
b(lWm);
|
|
}
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onError(Throwable th) {
|
|
this.j = th;
|
|
this.f = true;
|
|
for (LWm<T> lWm : this.d.getAndSet(a)) {
|
|
b(lWm);
|
|
}
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onComplete() {
|
|
this.f = true;
|
|
for (LWm<T> lWm : this.d.getAndSet(a)) {
|
|
b(lWm);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* renamed from: o.fVo$LWm */
|
|
/* loaded from: classes6.dex */
|
|
public static final class LWm<T> extends AtomicInteger implements fSJ {
|
|
long a;
|
|
volatile boolean b;
|
|
final InterfaceC13174fSv<? super T> c;
|
|
Sts<T> d;
|
|
int e;
|
|
private C13271fVo<T> h;
|
|
|
|
LWm(InterfaceC13174fSv<? super T> interfaceC13174fSv, C13271fVo<T> c13271fVo) {
|
|
this.c = interfaceC13174fSv;
|
|
this.h = c13271fVo;
|
|
this.d = c13271fVo.b;
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final void dispose() {
|
|
LWm<T>[] lWmArr;
|
|
if (this.b) {
|
|
return;
|
|
}
|
|
this.b = true;
|
|
C13271fVo<T> c13271fVo = this.h;
|
|
while (true) {
|
|
LWm<T>[] lWmArr2 = c13271fVo.d.get();
|
|
int length = lWmArr2.length;
|
|
if (length != 0) {
|
|
int i = 0;
|
|
while (true) {
|
|
if (i >= length) {
|
|
i = -1;
|
|
break;
|
|
} else if (lWmArr2[i] == this) {
|
|
break;
|
|
} else {
|
|
i++;
|
|
}
|
|
}
|
|
if (i >= 0) {
|
|
if (length == 1) {
|
|
lWmArr = C13271fVo.e;
|
|
} else {
|
|
LWm<T>[] lWmArr3 = new LWm[length - 1];
|
|
System.arraycopy(lWmArr2, 0, lWmArr3, 0, i);
|
|
System.arraycopy(lWmArr2, i + 1, lWmArr3, i, (length - i) - 1);
|
|
lWmArr = lWmArr3;
|
|
}
|
|
AtomicReference<LWm<T>[]> atomicReference = c13271fVo.d;
|
|
while (!atomicReference.compareAndSet(lWmArr2, lWmArr)) {
|
|
if (atomicReference.get() != lWmArr2) {
|
|
break;
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final boolean isDisposed() {
|
|
return this.b;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* renamed from: o.fVo$Sts */
|
|
/* loaded from: classes6.dex */
|
|
public static final class Sts<T> {
|
|
final T[] b;
|
|
volatile Sts<T> e;
|
|
|
|
Sts(int i) {
|
|
this.b = (T[]) new Object[i];
|
|
}
|
|
}
|
|
}
|