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

205 lines
6.6 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package o;
import io.reactivex.rxjava3.exceptions.CompositeException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import o.AbstractC13173fSu;
/* loaded from: classes6.dex */
public final class fXC<T> extends fUX<T, T> {
private long a;
private boolean b;
private fSQ<? super T> d;
private AbstractC13173fSu e;
private TimeUnit j;
public fXC(AbstractC13163fSk<T> abstractC13163fSk, long j, TimeUnit timeUnit, AbstractC13173fSu abstractC13173fSu, boolean z, fSQ<? super T> fsq) {
super(abstractC13163fSk);
this.a = j;
this.j = timeUnit;
this.e = abstractC13173fSu;
this.b = z;
this.d = fsq;
}
@Override // o.AbstractC13163fSk
public final void subscribeActual(InterfaceC13174fSv<? super T> interfaceC13174fSv) {
this.c.subscribe(new IeS(interfaceC13174fSv, this.a, this.j, this.e.c(), this.b, this.d));
}
/* loaded from: classes6.dex */
static final class IeS<T> extends AtomicInteger implements InterfaceC13174fSv<T>, fSJ, Runnable {
private Throwable a;
private volatile boolean b;
private InterfaceC13174fSv<? super T> c;
private volatile boolean d;
private boolean e;
private AtomicReference<T> f = new AtomicReference<>();
private fSQ<? super T> g;
private volatile boolean h;
private boolean i;
private long j;
private fSJ l;
private AbstractC13173fSu.Sts m;
private TimeUnit n;
IeS(InterfaceC13174fSv<? super T> interfaceC13174fSv, long j, TimeUnit timeUnit, AbstractC13173fSu.Sts sts, boolean z, fSQ<? super T> fsq) {
this.c = interfaceC13174fSv;
this.j = j;
this.n = timeUnit;
this.m = sts;
this.e = z;
this.g = fsq;
}
@Override // o.InterfaceC13174fSv
public final void onSubscribe(fSJ fsj) {
if (EnumC13192fTf.d(this.l, fsj)) {
this.l = fsj;
this.c.onSubscribe(this);
}
}
@Override // o.InterfaceC13174fSv
public final void onNext(T t) {
T andSet = this.f.getAndSet(t);
fSQ<? super T> fsq = this.g;
if (fsq != null && andSet != null) {
try {
fsq.c(andSet);
} catch (Throwable th) {
C13147fSI.c(th);
this.l.dispose();
this.a = th;
this.b = true;
}
}
c();
}
@Override // o.InterfaceC13174fSv
public final void onError(Throwable th) {
this.a = th;
this.b = true;
c();
}
@Override // o.InterfaceC13174fSv
public final void onComplete() {
this.b = true;
c();
}
@Override // o.fSJ
public final void dispose() {
this.d = true;
this.l.dispose();
this.m.dispose();
if (getAndIncrement() == 0) {
a();
}
}
private void a() {
if (this.g != null) {
T andSet = this.f.getAndSet(null);
if (andSet != null) {
try {
this.g.c(andSet);
return;
} catch (Throwable th) {
C13147fSI.c(th);
C13418fZu.c(th);
return;
}
}
return;
}
this.f.lazySet(null);
}
@Override // java.lang.Runnable
public final void run() {
this.h = true;
c();
}
private void c() {
if (getAndIncrement() != 0) {
return;
}
AtomicReference<T> atomicReference = this.f;
InterfaceC13174fSv<? super T> interfaceC13174fSv = this.c;
int i = 1;
while (!this.d) {
boolean z = this.b;
Throwable th = this.a;
if (z && th != null) {
if (this.g != null) {
T andSet = atomicReference.getAndSet(null);
if (andSet != null) {
try {
this.g.c(andSet);
} catch (Throwable th2) {
C13147fSI.c(th2);
th = new CompositeException(th, th2);
}
}
} else {
atomicReference.lazySet(null);
}
interfaceC13174fSv.onError(th);
this.m.dispose();
return;
}
boolean z2 = atomicReference.get() == null;
if (z) {
if (!z2) {
T andSet2 = atomicReference.getAndSet(null);
if (this.e) {
interfaceC13174fSv.onNext(andSet2);
} else {
fSQ<? super T> fsq = this.g;
if (fsq != null) {
try {
fsq.c(andSet2);
} catch (Throwable th3) {
C13147fSI.c(th3);
interfaceC13174fSv.onError(th3);
this.m.dispose();
return;
}
}
}
}
interfaceC13174fSv.onComplete();
this.m.dispose();
return;
}
if (z2) {
if (this.h) {
this.i = false;
this.h = false;
}
} else if (!this.i || this.h) {
interfaceC13174fSv.onNext(atomicReference.getAndSet(null));
this.h = false;
this.i = true;
this.m.a(this, this.j, this.n);
}
i = addAndGet(-i);
if (i == 0) {
return;
}
}
a();
}
@Override // o.fSJ
public final boolean isDisposed() {
return this.d;
}
}
}