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

293 lines
9.7 KiB
Java

package o;
import java.util.Arrays;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.atomic.AtomicReferenceArray;
/* loaded from: classes6.dex */
public final class fXS<T, R> extends fUX<T, R> {
private Iterable<? extends InterfaceC13169fSq<?>> a;
private InterfaceC13169fSq<?>[] d;
final fSS<? super Object[], R> e;
public fXS(InterfaceC13169fSq<T> interfaceC13169fSq, InterfaceC13169fSq<?>[] interfaceC13169fSqArr, fSS<? super Object[], R> fss) {
super(interfaceC13169fSq);
this.d = interfaceC13169fSqArr;
this.a = null;
this.e = fss;
}
public fXS(InterfaceC13169fSq<T> interfaceC13169fSq, Iterable<? extends InterfaceC13169fSq<?>> iterable, fSS<? super Object[], R> fss) {
super(interfaceC13169fSq);
this.d = null;
this.a = iterable;
this.e = fss;
}
@Override // o.AbstractC13163fSk
public final void subscribeActual(InterfaceC13174fSv<? super R> interfaceC13174fSv) {
int length;
InterfaceC13169fSq<?>[] interfaceC13169fSqArr = this.d;
if (interfaceC13169fSqArr == null) {
interfaceC13169fSqArr = new InterfaceC13169fSq[8];
try {
length = 0;
for (InterfaceC13169fSq<?> interfaceC13169fSq : this.a) {
if (length == interfaceC13169fSqArr.length) {
interfaceC13169fSqArr = (InterfaceC13169fSq[]) Arrays.copyOf(interfaceC13169fSqArr, (length >> 1) + length);
}
interfaceC13169fSqArr[length] = interfaceC13169fSq;
length++;
}
} catch (Throwable th) {
C13147fSI.c(th);
EnumC13195fTi.a(th, interfaceC13174fSv);
return;
}
} else {
length = interfaceC13169fSqArr.length;
}
if (length == 0) {
new C13314fWw(this.c, new HBt(this)).subscribeActual(interfaceC13174fSv);
return;
}
RVV rvv = new RVV(interfaceC13174fSv, this.e, length);
interfaceC13174fSv.onSubscribe(rvv);
IeS[] ieSArr = rvv.e;
AtomicReference<fSJ> atomicReference = rvv.a;
for (int i = 0; i < length && !EnumC13192fTf.c(atomicReference.get()) && !rvv.b; i++) {
interfaceC13169fSqArr[i].subscribe(ieSArr[i]);
}
this.c.subscribe(rvv);
}
/* loaded from: classes6.dex */
static final class RVV<T, R> extends AtomicInteger implements InterfaceC13174fSv<T>, fSJ {
final AtomicReference<fSJ> a;
volatile boolean b;
final InterfaceC13174fSv<? super R> c;
final C13355fYI d;
final IeS[] e;
private fSS<? super Object[], R> g;
final AtomicReferenceArray<Object> j;
RVV(InterfaceC13174fSv<? super R> interfaceC13174fSv, fSS<? super Object[], R> fss, int i) {
this.c = interfaceC13174fSv;
this.g = fss;
IeS[] ieSArr = new IeS[i];
for (int i2 = 0; i2 < i; i2++) {
ieSArr[i2] = new IeS(this, i2);
}
this.e = ieSArr;
this.j = new AtomicReferenceArray<>(i);
this.a = new AtomicReference<>();
this.d = new C13355fYI();
}
@Override // o.InterfaceC13174fSv
public final void onSubscribe(fSJ fsj) {
EnumC13192fTf.a(this.a, fsj);
}
@Override // o.InterfaceC13174fSv
public final void onNext(T t) {
if (this.b) {
return;
}
AtomicReferenceArray<Object> atomicReferenceArray = this.j;
int length = atomicReferenceArray.length();
Object[] objArr = new Object[length + 1];
int i = 0;
objArr[0] = t;
while (i < length) {
Object obj = atomicReferenceArray.get(i);
if (obj == null) {
return;
}
i++;
objArr[i] = obj;
}
try {
fYQ.b(this.c, Objects.requireNonNull(this.g.a(objArr), "combiner returned a null value"), this, this.d);
} catch (Throwable th) {
C13147fSI.c(th);
dispose();
onError(th);
}
}
@Override // o.InterfaceC13174fSv
public final void onError(Throwable th) {
if (this.b) {
C13418fZu.c(th);
return;
}
this.b = true;
IeS[] ieSArr = this.e;
for (int i = 0; i < ieSArr.length; i++) {
if (i != -1) {
EnumC13192fTf.e(ieSArr[i]);
}
}
InterfaceC13174fSv<? super R> interfaceC13174fSv = this.c;
C13355fYI c13355fYI = this.d;
if (fYR.c(c13355fYI, th)) {
if (getAndIncrement() == 0) {
Throwable b = fYR.b(c13355fYI);
if (b == null) {
interfaceC13174fSv.onComplete();
return;
} else {
if (b != fYR.b) {
interfaceC13174fSv.onError(b);
return;
}
return;
}
}
return;
}
C13418fZu.c(th);
}
@Override // o.InterfaceC13174fSv
public final void onComplete() {
if (this.b) {
return;
}
this.b = true;
IeS[] ieSArr = this.e;
for (int i = 0; i < ieSArr.length; i++) {
if (i != -1) {
EnumC13192fTf.e(ieSArr[i]);
}
}
InterfaceC13174fSv<? super R> interfaceC13174fSv = this.c;
C13355fYI c13355fYI = this.d;
if (getAndIncrement() == 0) {
Throwable b = fYR.b(c13355fYI);
if (b == null) {
interfaceC13174fSv.onComplete();
} else if (b != fYR.b) {
interfaceC13174fSv.onError(b);
}
}
}
@Override // o.fSJ
public final boolean isDisposed() {
return EnumC13192fTf.c(this.a.get());
}
@Override // o.fSJ
public final void dispose() {
EnumC13192fTf.e(this.a);
for (IeS ieS : this.e) {
EnumC13192fTf.e(ieS);
}
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public static final class IeS extends AtomicReference<fSJ> implements InterfaceC13174fSv<Object> {
private RVV<?, ?> a;
private int c;
private boolean d;
IeS(RVV<?, ?> rvv, int i) {
this.a = rvv;
this.c = i;
}
@Override // o.InterfaceC13174fSv
public final void onSubscribe(fSJ fsj) {
EnumC13192fTf.a(this, fsj);
}
@Override // o.InterfaceC13174fSv
public final void onNext(Object obj) {
if (!this.d) {
this.d = true;
}
RVV<?, ?> rvv = this.a;
rvv.j.set(this.c, obj);
}
@Override // o.InterfaceC13174fSv
public final void onError(Throwable th) {
RVV<?, ?> rvv = this.a;
int i = this.c;
rvv.b = true;
EnumC13192fTf.e(rvv.a);
IeS[] ieSArr = rvv.e;
for (int i2 = 0; i2 < ieSArr.length; i2++) {
if (i2 != i) {
EnumC13192fTf.e(ieSArr[i2]);
}
}
InterfaceC13174fSv<? super Object> interfaceC13174fSv = rvv.c;
C13355fYI c13355fYI = rvv.d;
if (fYR.c(c13355fYI, th)) {
if (rvv.getAndIncrement() == 0) {
Throwable b = fYR.b(c13355fYI);
if (b == null) {
interfaceC13174fSv.onComplete();
return;
} else {
if (b != fYR.b) {
interfaceC13174fSv.onError(b);
return;
}
return;
}
}
return;
}
C13418fZu.c(th);
}
@Override // o.InterfaceC13174fSv
public final void onComplete() {
RVV<?, ?> rvv = this.a;
int i = this.c;
if (this.d) {
return;
}
rvv.b = true;
IeS[] ieSArr = rvv.e;
for (int i2 = 0; i2 < ieSArr.length; i2++) {
if (i2 != i) {
EnumC13192fTf.e(ieSArr[i2]);
}
}
InterfaceC13174fSv<? super Object> interfaceC13174fSv = rvv.c;
C13355fYI c13355fYI = rvv.d;
if (rvv.getAndIncrement() == 0) {
Throwable b = fYR.b(c13355fYI);
if (b == null) {
interfaceC13174fSv.onComplete();
} else if (b != fYR.b) {
interfaceC13174fSv.onError(b);
}
}
}
}
/* loaded from: classes6.dex */
final class HBt implements fSS<T, R> {
private fXS b;
HBt(fXS fxs) {
this.b = fxs;
}
@Override // o.fSS
public final R a(T t) throws Throwable {
return (R) Objects.requireNonNull(this.b.e.a(new Object[]{t}), "The combiner returned a null value");
}
}
}