526 lines
17 KiB
Java
526 lines
17 KiB
Java
package o;
|
|
|
|
import java.util.ArrayDeque;
|
|
import java.util.Objects;
|
|
import java.util.Queue;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
/* loaded from: classes6.dex */
|
|
public final class fVQ<T, U> extends fUX<T, U> {
|
|
private fSS<? super T, ? extends InterfaceC13169fSq<? extends U>> a;
|
|
private boolean b;
|
|
private int d;
|
|
private int e;
|
|
|
|
public fVQ(InterfaceC13169fSq<T> interfaceC13169fSq, fSS<? super T, ? extends InterfaceC13169fSq<? extends U>> fss, boolean z, int i, int i2) {
|
|
super(interfaceC13169fSq);
|
|
this.a = fss;
|
|
this.b = z;
|
|
this.d = i;
|
|
this.e = i2;
|
|
}
|
|
|
|
@Override // o.AbstractC13163fSk
|
|
public final void subscribeActual(InterfaceC13174fSv<? super U> interfaceC13174fSv) {
|
|
if (C13328fXb.d(this.c, interfaceC13174fSv, this.a)) {
|
|
return;
|
|
}
|
|
this.c.subscribe(new Sts(interfaceC13174fSv, this.a, this.b, this.d, this.e));
|
|
}
|
|
|
|
/* loaded from: classes6.dex */
|
|
static final class Sts<T, U> extends AtomicInteger implements fSJ, InterfaceC13174fSv<T> {
|
|
final C13355fYI a = new C13355fYI();
|
|
final int b;
|
|
final boolean d;
|
|
final InterfaceC13174fSv<? super U> e;
|
|
private int f;
|
|
private volatile boolean g;
|
|
private volatile boolean h;
|
|
private fSS<? super T, ? extends InterfaceC13169fSq<? extends U>> i;
|
|
private volatile InterfaceC13408fZk<U> k;
|
|
private Queue<InterfaceC13169fSq<? extends U>> l;
|
|
private AtomicReference<RVV<?, ?>[]> m;
|
|
private long n;
|
|
|
|
/* renamed from: o, reason: collision with root package name */
|
|
private int f9113o;
|
|
private int q;
|
|
private fSJ r;
|
|
private static RVV<?, ?>[] j = new RVV[0];
|
|
private static RVV<?, ?>[] c = new RVV[0];
|
|
|
|
Sts(InterfaceC13174fSv<? super U> interfaceC13174fSv, fSS<? super T, ? extends InterfaceC13169fSq<? extends U>> fss, boolean z, int i, int i2) {
|
|
this.e = interfaceC13174fSv;
|
|
this.i = fss;
|
|
this.d = z;
|
|
this.f9113o = i;
|
|
this.b = i2;
|
|
if (i != Integer.MAX_VALUE) {
|
|
this.l = new ArrayDeque(i);
|
|
}
|
|
this.m = new AtomicReference<>(j);
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onSubscribe(fSJ fsj) {
|
|
if (EnumC13192fTf.d(this.r, fsj)) {
|
|
this.r = fsj;
|
|
this.e.onSubscribe(this);
|
|
}
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onNext(T t) {
|
|
if (this.h) {
|
|
return;
|
|
}
|
|
try {
|
|
InterfaceC13169fSq<? extends U> interfaceC13169fSq = (InterfaceC13169fSq) Objects.requireNonNull(this.i.a(t), "The mapper returned a null ObservableSource");
|
|
if (this.f9113o != Integer.MAX_VALUE) {
|
|
synchronized (this) {
|
|
int i = this.q;
|
|
if (i == this.f9113o) {
|
|
this.l.offer(interfaceC13169fSq);
|
|
return;
|
|
}
|
|
this.q = i + 1;
|
|
}
|
|
}
|
|
d(interfaceC13169fSq);
|
|
} catch (Throwable th) {
|
|
C13147fSI.c(th);
|
|
this.r.dispose();
|
|
onError(th);
|
|
}
|
|
}
|
|
|
|
private void d(InterfaceC13169fSq<? extends U> interfaceC13169fSq) {
|
|
boolean z;
|
|
while (interfaceC13169fSq instanceof InterfaceC13189fTc) {
|
|
if (!c((InterfaceC13189fTc) interfaceC13169fSq) || this.f9113o == Integer.MAX_VALUE) {
|
|
return;
|
|
}
|
|
synchronized (this) {
|
|
interfaceC13169fSq = this.l.poll();
|
|
if (interfaceC13169fSq == null) {
|
|
z = true;
|
|
this.q--;
|
|
} else {
|
|
z = false;
|
|
}
|
|
}
|
|
if (z) {
|
|
if (getAndIncrement() == 0) {
|
|
b();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
long j2 = this.n;
|
|
this.n = 1 + j2;
|
|
RVV<T, U> rvv = new RVV<>(this, j2);
|
|
if (e(rvv)) {
|
|
interfaceC13169fSq.subscribe(rvv);
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
private boolean e(RVV<T, U> rvv) {
|
|
while (true) {
|
|
RVV<?, ?>[] rvvArr = this.m.get();
|
|
if (rvvArr != c) {
|
|
int length = rvvArr.length;
|
|
RVV[] rvvArr2 = new RVV[length + 1];
|
|
System.arraycopy(rvvArr, 0, rvvArr2, 0, length);
|
|
rvvArr2[length] = rvv;
|
|
AtomicReference<RVV<?, ?>[]> atomicReference = this.m;
|
|
while (!atomicReference.compareAndSet(rvvArr, rvvArr2)) {
|
|
if (atomicReference.get() != rvvArr) {
|
|
break;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
EnumC13192fTf.e(rvv);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
private void d(RVV<T, U> rvv) {
|
|
RVV<?, ?>[] rvvArr;
|
|
while (true) {
|
|
RVV<?, ?>[] rvvArr2 = this.m.get();
|
|
int length = rvvArr2.length;
|
|
int i = 0;
|
|
while (true) {
|
|
if (i >= length) {
|
|
i = -1;
|
|
break;
|
|
} else if (rvvArr2[i] == rvv) {
|
|
break;
|
|
} else {
|
|
i++;
|
|
}
|
|
}
|
|
if (i < 0) {
|
|
return;
|
|
}
|
|
if (length == 1) {
|
|
rvvArr = j;
|
|
} else {
|
|
RVV<?, ?>[] rvvArr3 = new RVV[length - 1];
|
|
System.arraycopy(rvvArr2, 0, rvvArr3, 0, i);
|
|
System.arraycopy(rvvArr2, i + 1, rvvArr3, i, (length - i) - 1);
|
|
rvvArr = rvvArr3;
|
|
}
|
|
AtomicReference<RVV<?, ?>[]> atomicReference = this.m;
|
|
while (!atomicReference.compareAndSet(rvvArr2, rvvArr)) {
|
|
if (atomicReference.get() != rvvArr2) {
|
|
break;
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
|
|
private boolean c(InterfaceC13189fTc<? extends U> interfaceC13189fTc) {
|
|
try {
|
|
U d = interfaceC13189fTc.d();
|
|
if (d == null) {
|
|
return true;
|
|
}
|
|
if (get() == 0 && compareAndSet(0, 1)) {
|
|
this.e.onNext(d);
|
|
if (decrementAndGet() == 0) {
|
|
return true;
|
|
}
|
|
} else {
|
|
InterfaceC13408fZk<U> interfaceC13408fZk = this.k;
|
|
if (interfaceC13408fZk == null) {
|
|
if (this.f9113o == Integer.MAX_VALUE) {
|
|
interfaceC13408fZk = new C13416fZs<>(this.b);
|
|
} else {
|
|
interfaceC13408fZk = new C13415fZr<>(this.f9113o);
|
|
}
|
|
this.k = interfaceC13408fZk;
|
|
}
|
|
interfaceC13408fZk.b(d);
|
|
if (getAndIncrement() != 0) {
|
|
return false;
|
|
}
|
|
}
|
|
b();
|
|
return true;
|
|
} catch (Throwable th) {
|
|
C13147fSI.c(th);
|
|
if (!fYR.c(this.a, th)) {
|
|
C13418fZu.c(th);
|
|
}
|
|
if (getAndIncrement() == 0) {
|
|
b();
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onError(Throwable th) {
|
|
if (this.h) {
|
|
C13418fZu.c(th);
|
|
return;
|
|
}
|
|
if (fYR.c(this.a, th)) {
|
|
this.h = true;
|
|
if (getAndIncrement() == 0) {
|
|
b();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
C13418fZu.c(th);
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final void dispose() {
|
|
Throwable b;
|
|
this.g = true;
|
|
if (!c() || (b = fYR.b(this.a)) == null || b == fYR.b) {
|
|
return;
|
|
}
|
|
C13418fZu.c(b);
|
|
}
|
|
|
|
/* JADX WARN: Code restructure failed: missing block: B:46:0x008a, code lost:
|
|
|
|
if (r10 != null) goto L86;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:47:0x00bf, code lost:
|
|
|
|
r10 = r9.e;
|
|
r11 = r9.c;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:48:0x00c3, code lost:
|
|
|
|
if (r10 == false) goto L72;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:49:0x00c5, code lost:
|
|
|
|
if (r11 == null) goto L71;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:51:0x00cb, code lost:
|
|
|
|
if (r11.c() == false) goto L72;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:52:0x00cd, code lost:
|
|
|
|
d(r9);
|
|
r4 = r4 + 1;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:53:0x00d2, code lost:
|
|
|
|
r5 = r5 + 1;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:54:0x00d4, code lost:
|
|
|
|
if (r5 != r8) goto L111;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:55:0x00d6, code lost:
|
|
|
|
r5 = 0;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:57:0x00d7, code lost:
|
|
|
|
r6 = r6 + 1;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:60:0x008c, code lost:
|
|
|
|
r11 = r10.b();
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:61:0x0090, code lost:
|
|
|
|
if (r11 == null) goto L112;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:62:0x0092, code lost:
|
|
|
|
r0.onNext(r11);
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:63:0x0099, code lost:
|
|
|
|
if (e() == false) goto L113;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:65:0x009b, code lost:
|
|
|
|
return;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:69:0x009c, code lost:
|
|
|
|
r10 = move-exception;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:70:0x009d, code lost:
|
|
|
|
o.C13147fSI.c(r10);
|
|
o.EnumC13192fTf.e(r9);
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:71:0x00a9, code lost:
|
|
|
|
if (o.fYR.c(r12.a, r10) == false) goto L59;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:72:0x00ab, code lost:
|
|
|
|
o.C13418fZu.c(r10);
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:74:0x00b2, code lost:
|
|
|
|
if (e() != false) goto L95;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:75:0x00b5, code lost:
|
|
|
|
d(r9);
|
|
r4 = r4 + 1;
|
|
r5 = r5 + 1;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:76:0x00bc, code lost:
|
|
|
|
if (r5 != r8) goto L110;
|
|
*/
|
|
/* JADX WARN: Code restructure failed: missing block: B:79:0x00b4, code lost:
|
|
|
|
return;
|
|
*/
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
final void b() {
|
|
/*
|
|
Method dump skipped, instructions count: 239
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: o.fVQ.Sts.b():void");
|
|
}
|
|
|
|
private void d(int i) {
|
|
while (i != 0) {
|
|
synchronized (this) {
|
|
InterfaceC13169fSq<? extends U> poll = this.l.poll();
|
|
if (poll == null) {
|
|
this.q--;
|
|
} else {
|
|
d(poll);
|
|
}
|
|
}
|
|
i--;
|
|
}
|
|
}
|
|
|
|
private boolean e() {
|
|
if (this.g) {
|
|
return true;
|
|
}
|
|
Throwable th = this.a.get();
|
|
if (this.d || th == null) {
|
|
return false;
|
|
}
|
|
c();
|
|
C13355fYI c13355fYI = this.a;
|
|
InterfaceC13174fSv<? super U> interfaceC13174fSv = this.e;
|
|
Throwable b = fYR.b(c13355fYI);
|
|
if (b == null) {
|
|
interfaceC13174fSv.onComplete();
|
|
} else if (b != fYR.b) {
|
|
interfaceC13174fSv.onError(b);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
final boolean c() {
|
|
this.r.dispose();
|
|
AtomicReference<RVV<?, ?>[]> atomicReference = this.m;
|
|
RVV<?, ?>[] rvvArr = c;
|
|
RVV<?, ?>[] andSet = atomicReference.getAndSet(rvvArr);
|
|
if (andSet == rvvArr) {
|
|
return false;
|
|
}
|
|
for (RVV<?, ?> rvv : andSet) {
|
|
EnumC13192fTf.e(rvv);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onComplete() {
|
|
if (this.h) {
|
|
return;
|
|
}
|
|
this.h = true;
|
|
if (getAndIncrement() == 0) {
|
|
b();
|
|
}
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final boolean isDisposed() {
|
|
return this.g;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes6.dex */
|
|
public static final class RVV<T, U> extends AtomicReference<fSJ> implements InterfaceC13174fSv<U> {
|
|
private long a;
|
|
private Sts<T, U> b;
|
|
volatile InterfaceC13414fZq<U> c;
|
|
private int d;
|
|
volatile boolean e;
|
|
|
|
RVV(Sts<T, U> sts, long j) {
|
|
this.a = j;
|
|
this.b = sts;
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onSubscribe(fSJ fsj) {
|
|
if (EnumC13192fTf.a(this, fsj) && (fsj instanceof InterfaceC13412fZo)) {
|
|
InterfaceC13412fZo interfaceC13412fZo = (InterfaceC13412fZo) fsj;
|
|
int b = interfaceC13412fZo.b(7);
|
|
if (b != 1) {
|
|
if (b == 2) {
|
|
this.d = b;
|
|
this.c = interfaceC13412fZo;
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
this.d = b;
|
|
this.c = interfaceC13412fZo;
|
|
this.e = true;
|
|
Sts<T, U> sts = this.b;
|
|
if (sts.getAndIncrement() == 0) {
|
|
sts.b();
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onError(Throwable th) {
|
|
if (fYR.c(this.b.a, th)) {
|
|
if (!this.b.d) {
|
|
this.b.c();
|
|
}
|
|
this.e = true;
|
|
Sts<T, U> sts = this.b;
|
|
if (sts.getAndIncrement() == 0) {
|
|
sts.b();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
C13418fZu.c(th);
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onComplete() {
|
|
this.e = true;
|
|
Sts<T, U> sts = this.b;
|
|
if (sts.getAndIncrement() == 0) {
|
|
sts.b();
|
|
}
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onNext(U u) {
|
|
if (this.d != 0) {
|
|
Sts<T, U> sts = this.b;
|
|
if (sts.getAndIncrement() == 0) {
|
|
sts.b();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
Sts<T, U> sts2 = this.b;
|
|
if (sts2.get() == 0 && sts2.compareAndSet(0, 1)) {
|
|
sts2.e.onNext(u);
|
|
if (sts2.decrementAndGet() == 0) {
|
|
return;
|
|
}
|
|
} else {
|
|
InterfaceC13414fZq interfaceC13414fZq = this.c;
|
|
if (interfaceC13414fZq == null) {
|
|
interfaceC13414fZq = new C13416fZs(sts2.b);
|
|
this.c = interfaceC13414fZq;
|
|
}
|
|
interfaceC13414fZq.b(u);
|
|
if (sts2.getAndIncrement() != 0) {
|
|
return;
|
|
}
|
|
}
|
|
sts2.b();
|
|
}
|
|
}
|
|
}
|