232 lines
7.7 KiB
Java
232 lines
7.7 KiB
Java
|
package o;
|
||
|
|
||
|
import java.util.Objects;
|
||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||
|
import java.util.concurrent.atomic.AtomicReference;
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
public final class fUQ<T, R> extends AbstractC13163fSk<R> {
|
||
|
private boolean a;
|
||
|
private fSS<? super T, ? extends fSD<? extends R>> b;
|
||
|
private AbstractC13163fSk<T> c;
|
||
|
|
||
|
public fUQ(AbstractC13163fSk<T> abstractC13163fSk, fSS<? super T, ? extends fSD<? extends R>> fss, boolean z) {
|
||
|
this.c = abstractC13163fSk;
|
||
|
this.b = fss;
|
||
|
this.a = z;
|
||
|
}
|
||
|
|
||
|
@Override // o.AbstractC13163fSk
|
||
|
public final void subscribeActual(InterfaceC13174fSv<? super R> interfaceC13174fSv) {
|
||
|
if (fUP.a(this.c, this.b, interfaceC13174fSv)) {
|
||
|
return;
|
||
|
}
|
||
|
this.c.subscribe(new RVV(interfaceC13174fSv, this.b, this.a));
|
||
|
}
|
||
|
|
||
|
/* loaded from: classes6.dex */
|
||
|
static final class RVV<T, R> extends AtomicInteger implements InterfaceC13174fSv<T>, fSJ {
|
||
|
private static LWm<Object> e = new LWm<>(null);
|
||
|
fSJ b;
|
||
|
final boolean c;
|
||
|
private volatile boolean f;
|
||
|
private InterfaceC13174fSv<? super R> g;
|
||
|
private fSS<? super T, ? extends fSD<? extends R>> h;
|
||
|
private volatile boolean i;
|
||
|
final C13355fYI d = new C13355fYI();
|
||
|
final AtomicReference<LWm<R>> a = new AtomicReference<>();
|
||
|
|
||
|
RVV(InterfaceC13174fSv<? super R> interfaceC13174fSv, fSS<? super T, ? extends fSD<? extends R>> fss, boolean z) {
|
||
|
this.g = interfaceC13174fSv;
|
||
|
this.h = fss;
|
||
|
this.c = z;
|
||
|
}
|
||
|
|
||
|
@Override // o.InterfaceC13174fSv
|
||
|
public final void onSubscribe(fSJ fsj) {
|
||
|
if (EnumC13192fTf.d(this.b, fsj)) {
|
||
|
this.b = fsj;
|
||
|
this.g.onSubscribe(this);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // o.InterfaceC13174fSv
|
||
|
public final void onNext(T t) {
|
||
|
LWm<R> lWm = this.a.get();
|
||
|
if (lWm != null) {
|
||
|
EnumC13192fTf.e(lWm);
|
||
|
}
|
||
|
try {
|
||
|
fSD fsd = (fSD) Objects.requireNonNull(this.h.a(t), "The mapper returned a null SingleSource");
|
||
|
LWm<R> lWm2 = new LWm<>(this);
|
||
|
while (true) {
|
||
|
LWm<R> lWm3 = this.a.get();
|
||
|
if (lWm3 != e) {
|
||
|
AtomicReference<LWm<R>> atomicReference = this.a;
|
||
|
while (!atomicReference.compareAndSet(lWm3, lWm2)) {
|
||
|
if (atomicReference.get() != lWm3) {
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
fsd.c(lWm2);
|
||
|
return;
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
} catch (Throwable th) {
|
||
|
C13147fSI.c(th);
|
||
|
this.b.dispose();
|
||
|
this.a.getAndSet(e);
|
||
|
onError(th);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // o.InterfaceC13174fSv
|
||
|
public final void onComplete() {
|
||
|
this.f = true;
|
||
|
e();
|
||
|
}
|
||
|
|
||
|
final void c() {
|
||
|
AtomicReference<LWm<R>> atomicReference = this.a;
|
||
|
LWm<Object> lWm = e;
|
||
|
LWm<Object> lWm2 = (LWm) atomicReference.getAndSet(lWm);
|
||
|
if (lWm2 == null || lWm2 == lWm) {
|
||
|
return;
|
||
|
}
|
||
|
EnumC13192fTf.e(lWm2);
|
||
|
}
|
||
|
|
||
|
@Override // o.fSJ
|
||
|
public final void dispose() {
|
||
|
this.i = true;
|
||
|
this.b.dispose();
|
||
|
AtomicReference<LWm<R>> atomicReference = this.a;
|
||
|
LWm<Object> lWm = e;
|
||
|
LWm<Object> lWm2 = (LWm) atomicReference.getAndSet(lWm);
|
||
|
if (lWm2 != null && lWm2 != lWm) {
|
||
|
EnumC13192fTf.e(lWm2);
|
||
|
}
|
||
|
Throwable b = fYR.b(this.d);
|
||
|
if (b == null || b == fYR.b) {
|
||
|
return;
|
||
|
}
|
||
|
C13418fZu.c(b);
|
||
|
}
|
||
|
|
||
|
final void e() {
|
||
|
if (getAndIncrement() != 0) {
|
||
|
return;
|
||
|
}
|
||
|
InterfaceC13174fSv<? super R> interfaceC13174fSv = this.g;
|
||
|
C13355fYI c13355fYI = this.d;
|
||
|
AtomicReference<LWm<R>> atomicReference = this.a;
|
||
|
int i = 1;
|
||
|
while (!this.i) {
|
||
|
if (c13355fYI.get() == null || this.c) {
|
||
|
boolean z = this.f;
|
||
|
LWm<R> lWm = atomicReference.get();
|
||
|
boolean z2 = lWm == null;
|
||
|
if (!z || !z2) {
|
||
|
if (z2 || lWm.b == null) {
|
||
|
i = addAndGet(-i);
|
||
|
if (i == 0) {
|
||
|
return;
|
||
|
}
|
||
|
} else {
|
||
|
while (!atomicReference.compareAndSet(lWm, null) && atomicReference.get() == lWm) {
|
||
|
}
|
||
|
interfaceC13174fSv.onNext(lWm.b);
|
||
|
}
|
||
|
} else {
|
||
|
Throwable b = fYR.b(c13355fYI);
|
||
|
if (b == null) {
|
||
|
interfaceC13174fSv.onComplete();
|
||
|
return;
|
||
|
} else {
|
||
|
if (b != fYR.b) {
|
||
|
interfaceC13174fSv.onError(b);
|
||
|
return;
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
Throwable b2 = fYR.b(c13355fYI);
|
||
|
if (b2 == null) {
|
||
|
interfaceC13174fSv.onComplete();
|
||
|
return;
|
||
|
} else {
|
||
|
if (b2 != fYR.b) {
|
||
|
interfaceC13174fSv.onError(b2);
|
||
|
return;
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* loaded from: classes6.dex */
|
||
|
public static final class LWm<R> extends AtomicReference<fSJ> implements InterfaceC13176fSx<R> {
|
||
|
volatile R b;
|
||
|
private RVV<?, R> e;
|
||
|
|
||
|
LWm(RVV<?, R> rvv) {
|
||
|
this.e = rvv;
|
||
|
}
|
||
|
|
||
|
@Override // o.InterfaceC13176fSx
|
||
|
public final void onSubscribe(fSJ fsj) {
|
||
|
EnumC13192fTf.a(this, fsj);
|
||
|
}
|
||
|
|
||
|
@Override // o.InterfaceC13176fSx
|
||
|
public final void e(R r) {
|
||
|
this.b = r;
|
||
|
this.e.e();
|
||
|
}
|
||
|
|
||
|
@Override // o.InterfaceC13176fSx
|
||
|
public final void onError(Throwable th) {
|
||
|
RVV<?, R> rvv = this.e;
|
||
|
AtomicReference<LWm<R>> atomicReference = rvv.a;
|
||
|
while (!atomicReference.compareAndSet(this, null)) {
|
||
|
if (atomicReference.get() != this) {
|
||
|
C13418fZu.c(th);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
if (fYR.c(rvv.d, th)) {
|
||
|
if (!rvv.c) {
|
||
|
rvv.b.dispose();
|
||
|
rvv.c();
|
||
|
}
|
||
|
rvv.e();
|
||
|
return;
|
||
|
}
|
||
|
C13418fZu.c(th);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // o.InterfaceC13174fSv
|
||
|
public final void onError(Throwable th) {
|
||
|
if (fYR.c(this.d, th)) {
|
||
|
if (!this.c) {
|
||
|
c();
|
||
|
}
|
||
|
this.f = true;
|
||
|
e();
|
||
|
return;
|
||
|
}
|
||
|
C13418fZu.c(th);
|
||
|
}
|
||
|
|
||
|
@Override // o.fSJ
|
||
|
public final boolean isDisposed() {
|
||
|
return this.i;
|
||
|
}
|
||
|
}
|
||
|
}
|