170 lines
4.9 KiB
Java
170 lines
4.9 KiB
Java
package o;
|
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
/* renamed from: o.fZA, reason: case insensitive filesystem */
|
|
/* loaded from: classes6.dex */
|
|
public final class C13389fZA<T> extends AbstractC13422fZy<T> {
|
|
private Throwable b;
|
|
private AtomicReference<IeS<T>[]> d = new AtomicReference<>(c);
|
|
private static IeS[] e = new IeS[0];
|
|
private static IeS[] c = new IeS[0];
|
|
|
|
public static <T> C13389fZA<T> d() {
|
|
return new C13389fZA<>();
|
|
}
|
|
|
|
C13389fZA() {
|
|
}
|
|
|
|
@Override // o.AbstractC13163fSk
|
|
public final void subscribeActual(InterfaceC13174fSv<? super T> interfaceC13174fSv) {
|
|
IeS<T> ieS = new IeS<>(interfaceC13174fSv, this);
|
|
interfaceC13174fSv.onSubscribe(ieS);
|
|
while (true) {
|
|
IeS<T>[] ieSArr = this.d.get();
|
|
if (ieSArr == e) {
|
|
Throwable th = this.b;
|
|
if (th != null) {
|
|
interfaceC13174fSv.onError(th);
|
|
return;
|
|
} else {
|
|
interfaceC13174fSv.onComplete();
|
|
return;
|
|
}
|
|
}
|
|
int length = ieSArr.length;
|
|
IeS<T>[] ieSArr2 = new IeS[length + 1];
|
|
System.arraycopy(ieSArr, 0, ieSArr2, 0, length);
|
|
ieSArr2[length] = ieS;
|
|
AtomicReference<IeS<T>[]> atomicReference = this.d;
|
|
while (!atomicReference.compareAndSet(ieSArr, ieSArr2)) {
|
|
if (atomicReference.get() != ieSArr) {
|
|
break;
|
|
}
|
|
}
|
|
if (ieS.isDisposed()) {
|
|
b(ieS);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
|
|
final void b(IeS<T> ieS) {
|
|
IeS<T>[] ieSArr;
|
|
while (true) {
|
|
IeS<T>[] ieSArr2 = this.d.get();
|
|
if (ieSArr2 == e || ieSArr2 == c) {
|
|
return;
|
|
}
|
|
int length = ieSArr2.length;
|
|
int i = 0;
|
|
while (true) {
|
|
if (i >= length) {
|
|
i = -1;
|
|
break;
|
|
} else if (ieSArr2[i] == ieS) {
|
|
break;
|
|
} else {
|
|
i++;
|
|
}
|
|
}
|
|
if (i < 0) {
|
|
return;
|
|
}
|
|
if (length == 1) {
|
|
ieSArr = c;
|
|
} else {
|
|
IeS<T>[] ieSArr3 = new IeS[length - 1];
|
|
System.arraycopy(ieSArr2, 0, ieSArr3, 0, i);
|
|
System.arraycopy(ieSArr2, i + 1, ieSArr3, i, (length - i) - 1);
|
|
ieSArr = ieSArr3;
|
|
}
|
|
AtomicReference<IeS<T>[]> atomicReference = this.d;
|
|
while (!atomicReference.compareAndSet(ieSArr2, ieSArr)) {
|
|
if (atomicReference.get() != ieSArr2) {
|
|
break;
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onSubscribe(fSJ fsj) {
|
|
if (this.d.get() == e) {
|
|
fsj.dispose();
|
|
}
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onNext(T t) {
|
|
fYR.d(t, "onNext called with a null value.");
|
|
for (IeS<T> ieS : this.d.get()) {
|
|
if (!ieS.get()) {
|
|
ieS.e.onNext(t);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onError(Throwable th) {
|
|
fYR.d(th, "onError called with a null Throwable.");
|
|
IeS<T>[] ieSArr = this.d.get();
|
|
IeS<T>[] ieSArr2 = e;
|
|
if (ieSArr == ieSArr2) {
|
|
C13418fZu.c(th);
|
|
return;
|
|
}
|
|
this.b = th;
|
|
for (IeS<T> ieS : this.d.getAndSet(ieSArr2)) {
|
|
if (ieS.get()) {
|
|
C13418fZu.c(th);
|
|
} else {
|
|
ieS.e.onError(th);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onComplete() {
|
|
IeS<T>[] ieSArr = this.d.get();
|
|
IeS<T>[] ieSArr2 = e;
|
|
if (ieSArr == ieSArr2) {
|
|
return;
|
|
}
|
|
for (IeS<T> ieS : this.d.getAndSet(ieSArr2)) {
|
|
if (!ieS.get()) {
|
|
ieS.e.onComplete();
|
|
}
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* renamed from: o.fZA$IeS */
|
|
/* loaded from: classes6.dex */
|
|
public static final class IeS<T> extends AtomicBoolean implements fSJ {
|
|
private C13389fZA<T> a;
|
|
final InterfaceC13174fSv<? super T> e;
|
|
|
|
IeS(InterfaceC13174fSv<? super T> interfaceC13174fSv, C13389fZA<T> c13389fZA) {
|
|
this.e = interfaceC13174fSv;
|
|
this.a = c13389fZA;
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final void dispose() {
|
|
if (compareAndSet(false, true)) {
|
|
this.a.b(this);
|
|
}
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final boolean isDisposed() {
|
|
return get();
|
|
}
|
|
}
|
|
}
|