what-the-bank/sources/o/C13257fVa.java

170 lines
5.6 KiB
Java

package o;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
/* renamed from: o.fVa, reason: case insensitive filesystem */
/* loaded from: classes6.dex */
public final class C13257fVa<T> extends AbstractC13163fSk<T> {
private Iterable<? extends InterfaceC13169fSq<? extends T>> c;
private InterfaceC13169fSq<? extends T>[] d;
public C13257fVa(InterfaceC13169fSq<? extends T>[] interfaceC13169fSqArr, Iterable<? extends InterfaceC13169fSq<? extends T>> iterable) {
this.d = interfaceC13169fSqArr;
this.c = iterable;
}
@Override // o.AbstractC13163fSk
public final void subscribeActual(InterfaceC13174fSv<? super T> interfaceC13174fSv) {
int length;
InterfaceC13169fSq<? extends T>[] interfaceC13169fSqArr = this.d;
if (interfaceC13169fSqArr == null) {
interfaceC13169fSqArr = new InterfaceC13169fSq[8];
try {
length = 0;
for (InterfaceC13169fSq<? extends T> interfaceC13169fSq : this.c) {
if (interfaceC13169fSq == null) {
EnumC13195fTi.a(new NullPointerException("One of the sources is null"), interfaceC13174fSv);
return;
}
if (length == interfaceC13169fSqArr.length) {
InterfaceC13169fSq<? extends T>[] interfaceC13169fSqArr2 = new InterfaceC13169fSq[(length >> 2) + length];
System.arraycopy(interfaceC13169fSqArr, 0, interfaceC13169fSqArr2, 0, length);
interfaceC13169fSqArr = interfaceC13169fSqArr2;
}
interfaceC13169fSqArr[length] = interfaceC13169fSq;
length++;
}
} catch (Throwable th) {
C13147fSI.c(th);
EnumC13195fTi.a(th, interfaceC13174fSv);
return;
}
} else {
length = interfaceC13169fSqArr.length;
}
if (length == 0) {
EnumC13195fTi.e(interfaceC13174fSv);
return;
}
if (length == 1) {
interfaceC13169fSqArr[0].subscribe(interfaceC13174fSv);
return;
}
HBt hBt = new HBt(interfaceC13174fSv, length);
RVV<T>[] rvvArr = hBt.e;
int length2 = rvvArr.length;
int i = 0;
while (i < length2) {
int i2 = i + 1;
rvvArr[i] = new RVV<>(hBt, i2, hBt.b);
i = i2;
}
hBt.c.lazySet(0);
hBt.b.onSubscribe(hBt);
for (int i3 = 0; i3 < length2 && hBt.c.get() == 0; i3++) {
interfaceC13169fSqArr[i3].subscribe(rvvArr[i3]);
}
}
/* renamed from: o.fVa$HBt */
/* loaded from: classes6.dex */
static final class HBt<T> implements fSJ {
final InterfaceC13174fSv<? super T> b;
final AtomicInteger c = new AtomicInteger();
final RVV<T>[] e;
HBt(InterfaceC13174fSv<? super T> interfaceC13174fSv, int i) {
this.b = interfaceC13174fSv;
this.e = new RVV[i];
}
public final boolean c(int i) {
int i2 = 0;
if (this.c.get() != 0 || !this.c.compareAndSet(0, i)) {
return false;
}
RVV<T>[] rvvArr = this.e;
int length = rvvArr.length;
while (i2 < length) {
int i3 = i2 + 1;
if (i3 != i) {
EnumC13192fTf.e(rvvArr[i2]);
}
i2 = i3;
}
return true;
}
@Override // o.fSJ
public final void dispose() {
if (this.c.get() != -1) {
this.c.lazySet(-1);
for (RVV<T> rvv : this.e) {
EnumC13192fTf.e(rvv);
}
}
}
@Override // o.fSJ
public final boolean isDisposed() {
return this.c.get() == -1;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* renamed from: o.fVa$RVV */
/* loaded from: classes6.dex */
public static final class RVV<T> extends AtomicReference<fSJ> implements InterfaceC13174fSv<T> {
private InterfaceC13174fSv<? super T> a;
private int c;
private boolean d;
private HBt<T> e;
RVV(HBt<T> hBt, int i, InterfaceC13174fSv<? super T> interfaceC13174fSv) {
this.e = hBt;
this.c = i;
this.a = interfaceC13174fSv;
}
@Override // o.InterfaceC13174fSv
public final void onSubscribe(fSJ fsj) {
EnumC13192fTf.a(this, fsj);
}
@Override // o.InterfaceC13174fSv
public final void onNext(T t) {
if (this.d) {
this.a.onNext(t);
} else if (this.e.c(this.c)) {
this.d = true;
this.a.onNext(t);
} else {
get().dispose();
}
}
@Override // o.InterfaceC13174fSv
public final void onError(Throwable th) {
if (this.d) {
this.a.onError(th);
} else if (this.e.c(this.c)) {
this.d = true;
this.a.onError(th);
} else {
C13418fZu.c(th);
}
}
@Override // o.InterfaceC13174fSv
public final void onComplete() {
if (this.d) {
this.a.onComplete();
} else if (this.e.c(this.c)) {
this.d = true;
this.a.onComplete();
}
}
}
}