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

220 lines
6.5 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package o;
import io.reactivex.rxjava3.exceptions.MissingBackpressureException;
import java.util.concurrent.atomic.AtomicLong;
/* loaded from: classes.dex */
public final class fUB<T> extends AbstractC13240fUs<T, T> {
private fSP a;
private boolean b;
private boolean c;
private int d;
public fUB(AbstractC13155fSc<T> abstractC13155fSc, int i, fSP fsp) {
super(abstractC13155fSc);
this.d = i;
this.b = true;
this.c = false;
this.a = fsp;
}
@Override // o.AbstractC13155fSc
public final void c(InterfaceC15338gnn<? super T> interfaceC15338gnn) {
this.e.a((InterfaceC13158fSf) new LWm(interfaceC15338gnn, this.d, this.b, this.c, this.a));
}
/* loaded from: classes6.dex */
static final class LWm<T> extends fYD<T> implements InterfaceC13158fSf<T> {
private volatile boolean a;
private Throwable b;
private volatile boolean c;
private boolean d;
private InterfaceC15338gnn<? super T> e;
private fSP f;
private InterfaceC15337gnm g;
private InterfaceC13408fZk<T> h;
private AtomicLong i = new AtomicLong();
private boolean j;
LWm(InterfaceC15338gnn<? super T> interfaceC15338gnn, int i, boolean z, boolean z2, fSP fsp) {
InterfaceC13408fZk<T> c13415fZr;
this.e = interfaceC15338gnn;
this.f = fsp;
this.d = z2;
if (z) {
c13415fZr = new C13416fZs<>(i);
} else {
c13415fZr = new C13415fZr<>(i);
}
this.h = c13415fZr;
}
@Override // o.InterfaceC13158fSf, o.InterfaceC15338gnn
public final void c(InterfaceC15337gnm interfaceC15337gnm) {
if (fYC.e(this.g, interfaceC15337gnm)) {
this.g = interfaceC15337gnm;
this.e.c(this);
interfaceC15337gnm.c(Long.MAX_VALUE);
}
}
@Override // o.InterfaceC15338gnn
public final void onNext(T t) {
if (this.h.b(t)) {
if (this.j) {
this.e.onNext(null);
return;
} else {
d();
return;
}
}
this.g.a();
MissingBackpressureException missingBackpressureException = new MissingBackpressureException("Buffer is full");
try {
this.f.c();
} catch (Throwable th) {
C13147fSI.c(th);
missingBackpressureException.initCause(th);
}
onError(missingBackpressureException);
}
@Override // o.InterfaceC15338gnn
public final void onError(Throwable th) {
this.b = th;
this.a = true;
if (this.j) {
this.e.onError(th);
} else {
d();
}
}
@Override // o.InterfaceC15338gnn
public final void onComplete() {
this.a = true;
if (this.j) {
this.e.onComplete();
} else {
d();
}
}
@Override // o.InterfaceC15337gnm
public final void c(long j) {
if (this.j || !fYC.e(j)) {
return;
}
fYK.c(this.i, j);
d();
}
@Override // o.InterfaceC15337gnm
public final void a() {
if (this.c) {
return;
}
this.c = true;
this.g.a();
if (this.j || getAndIncrement() != 0) {
return;
}
this.h.e();
}
private void d() {
if (getAndIncrement() == 0) {
InterfaceC13408fZk<T> interfaceC13408fZk = this.h;
InterfaceC15338gnn<? super T> interfaceC15338gnn = this.e;
int i = 1;
while (!a(this.a, interfaceC13408fZk.c(), interfaceC15338gnn)) {
long j = this.i.get();
long j2 = 0;
while (j2 != j) {
boolean z = this.a;
T b = interfaceC13408fZk.b();
boolean z2 = b == null;
if (!a(z, z2, interfaceC15338gnn)) {
if (z2) {
break;
}
interfaceC15338gnn.onNext(b);
j2++;
} else {
return;
}
}
if (j2 == j && a(this.a, interfaceC13408fZk.c(), interfaceC15338gnn)) {
return;
}
if (j2 != 0 && j != Long.MAX_VALUE) {
this.i.addAndGet(-j2);
}
i = addAndGet(-i);
if (i == 0) {
return;
}
}
}
}
private boolean a(boolean z, boolean z2, InterfaceC15338gnn<? super T> interfaceC15338gnn) {
if (this.c) {
this.h.e();
return true;
}
if (!z) {
return false;
}
if (this.d) {
if (!z2) {
return false;
}
Throwable th = this.b;
if (th != null) {
interfaceC15338gnn.onError(th);
} else {
interfaceC15338gnn.onComplete();
}
return true;
}
Throwable th2 = this.b;
if (th2 != null) {
this.h.e();
interfaceC15338gnn.onError(th2);
return true;
}
if (!z2) {
return false;
}
interfaceC15338gnn.onComplete();
return true;
}
@Override // o.InterfaceC13414fZq
public final T b() {
return this.h.b();
}
@Override // o.InterfaceC13414fZq
public final void e() {
this.h.e();
}
@Override // o.InterfaceC13414fZq
public final boolean c() {
return this.h.c();
}
@Override // o.InterfaceC13413fZp
public final int b(int i) {
if ((i & 2) == 0) {
return 0;
}
this.j = true;
return 2;
}
}
}