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

719 lines
22 KiB
Java

package o;
import java.util.ArrayList;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
/* loaded from: classes6.dex */
public final class fWZ<T> extends fYZ<T> {
private static HBt d = new jNh();
private AtomicReference<tOB<T>> a;
private InterfaceC13169fSq<T> b;
private InterfaceC13169fSq<T> c;
private HBt<T> e;
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public interface HBt<T> {
jbe<T> d();
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public interface jbe<T> {
void b(Throwable th);
void b(Sts<T> sts);
void c(T t);
void d();
}
public static <U, R> AbstractC13163fSk<R> a(InterfaceC13189fTc<? extends fYZ<U>> interfaceC13189fTc, fSS<? super AbstractC13163fSk<U>, ? extends InterfaceC13169fSq<R>> fss) {
return new IeS(interfaceC13189fTc, fss);
}
public static <T> fYZ<T> b(InterfaceC13169fSq<T> interfaceC13169fSq, int i, boolean z) {
if (i == Integer.MAX_VALUE) {
HBt hBt = d;
AtomicReference atomicReference = new AtomicReference();
return new fWZ(new saX(atomicReference, hBt), interfaceC13169fSq, atomicReference, hBt);
}
ZqN zqN = new ZqN(i, z);
AtomicReference atomicReference2 = new AtomicReference();
return new fWZ(new saX(atomicReference2, zqN), interfaceC13169fSq, atomicReference2, zqN);
}
public static <T> fYZ<T> b(InterfaceC13169fSq<T> interfaceC13169fSq, long j, TimeUnit timeUnit, AbstractC13173fSu abstractC13173fSu, int i, boolean z) {
vUG vug = new vUG(i, j, timeUnit, abstractC13173fSu, z);
AtomicReference atomicReference = new AtomicReference();
return new fWZ(new saX(atomicReference, vug), interfaceC13169fSq, atomicReference, vug);
}
private fWZ(InterfaceC13169fSq<T> interfaceC13169fSq, InterfaceC13169fSq<T> interfaceC13169fSq2, AtomicReference<tOB<T>> atomicReference, HBt<T> hBt) {
this.c = interfaceC13169fSq;
this.b = interfaceC13169fSq2;
this.a = atomicReference;
this.e = hBt;
}
@Override // o.fYZ
public final void d() {
tOB<T> tob = this.a.get();
if (tob == null || !tob.isDisposed()) {
return;
}
AtomicReference<tOB<T>> atomicReference = this.a;
while (!atomicReference.compareAndSet(tob, null) && atomicReference.get() == tob) {
}
}
@Override // o.AbstractC13163fSk
public final void subscribeActual(InterfaceC13174fSv<? super T> interfaceC13174fSv) {
this.c.subscribe(interfaceC13174fSv);
}
@Override // o.fYZ
public final void d(fSQ<? super fSJ> fsq) {
tOB<T> tob;
loop0: while (true) {
tob = this.a.get();
if (tob != null && !tob.isDisposed()) {
break;
}
tOB<T> tob2 = new tOB<>(this.e.d(), this.a);
AtomicReference<tOB<T>> atomicReference = this.a;
while (!atomicReference.compareAndSet(tob, tob2)) {
if (atomicReference.get() != tob) {
break;
}
}
tob = tob2;
break loop0;
}
boolean z = !tob.b.get() && tob.b.compareAndSet(false, true);
try {
fsq.c(tob);
if (z) {
this.b.subscribe(tob);
}
} catch (Throwable th) {
C13147fSI.c(th);
if (z) {
tob.b.compareAndSet(true, false);
}
C13147fSI.c(th);
throw fYR.c(th);
}
}
/* loaded from: classes6.dex */
static final class tOB<T> extends AtomicReference<fSJ> implements InterfaceC13174fSv<T>, fSJ {
private static Sts[] a = new Sts[0];
static final Sts[] d = new Sts[0];
final jbe<T> c;
private AtomicReference<tOB<T>> h;
private boolean j;
final AtomicReference<Sts[]> e = new AtomicReference<>(a);
final AtomicBoolean b = new AtomicBoolean();
tOB(jbe<T> jbeVar, AtomicReference<tOB<T>> atomicReference) {
this.c = jbeVar;
this.h = atomicReference;
}
@Override // o.fSJ
public final boolean isDisposed() {
return this.e.get() == d;
}
@Override // o.fSJ
public final void dispose() {
this.e.set(d);
AtomicReference<tOB<T>> atomicReference = this.h;
while (!atomicReference.compareAndSet(this, null) && atomicReference.get() == this) {
}
EnumC13192fTf.e(this);
}
final void b(Sts<T> sts) {
Sts[] stsArr;
while (true) {
Sts[] stsArr2 = this.e.get();
int length = stsArr2.length;
if (length == 0) {
return;
}
int i = 0;
while (true) {
if (i >= length) {
i = -1;
break;
} else if (stsArr2[i].equals(sts)) {
break;
} else {
i++;
}
}
if (i < 0) {
return;
}
if (length == 1) {
stsArr = a;
} else {
Sts[] stsArr3 = new Sts[length - 1];
System.arraycopy(stsArr2, 0, stsArr3, 0, i);
System.arraycopy(stsArr2, i + 1, stsArr3, i, (length - i) - 1);
stsArr = stsArr3;
}
AtomicReference<Sts[]> atomicReference = this.e;
while (!atomicReference.compareAndSet(stsArr2, stsArr)) {
if (atomicReference.get() != stsArr2) {
break;
}
}
return;
}
}
@Override // o.InterfaceC13174fSv
public final void onSubscribe(fSJ fsj) {
if (EnumC13192fTf.a(this, fsj)) {
b();
}
}
@Override // o.InterfaceC13174fSv
public final void onNext(T t) {
if (this.j) {
return;
}
this.c.c(t);
b();
}
@Override // o.InterfaceC13174fSv
public final void onError(Throwable th) {
if (!this.j) {
this.j = true;
this.c.b(th);
c();
return;
}
C13418fZu.c(th);
}
@Override // o.InterfaceC13174fSv
public final void onComplete() {
if (this.j) {
return;
}
this.j = true;
this.c.d();
c();
}
private void b() {
for (Sts<T> sts : this.e.get()) {
this.c.b(sts);
}
}
private void c() {
for (Sts<T> sts : this.e.getAndSet(d)) {
this.c.b(sts);
}
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public static final class Sts<T> extends AtomicInteger implements fSJ {
Object a;
private tOB<T> b;
private volatile boolean c;
final InterfaceC13174fSv<? super T> e;
Sts(tOB<T> tob, InterfaceC13174fSv<? super T> interfaceC13174fSv) {
this.b = tob;
this.e = interfaceC13174fSv;
}
@Override // o.fSJ
public final void dispose() {
if (this.c) {
return;
}
this.c = true;
this.b.b(this);
this.a = null;
}
@Override // o.fSJ
public final boolean isDisposed() {
return this.c;
}
}
/* loaded from: classes6.dex */
static final class ZnX<T> extends ArrayList<Object> implements jbe<T> {
private volatile int c;
public ZnX() {
super(16);
}
@Override // o.fWZ.jbe
public final void c(T t) {
add(fYX.d(t));
this.c++;
}
@Override // o.fWZ.jbe
public final void b(Throwable th) {
add(fYX.a(th));
this.c++;
}
@Override // o.fWZ.jbe
public final void d() {
add(fYX.c());
this.c++;
}
@Override // o.fWZ.jbe
public final void b(Sts<T> sts) {
if (sts.getAndIncrement() != 0) {
return;
}
InterfaceC13174fSv<? super T> interfaceC13174fSv = sts.e;
int i = 1;
while (!sts.isDisposed()) {
int i2 = this.c;
Integer num = (Integer) sts.a;
int intValue = num != null ? num.intValue() : 0;
while (intValue < i2) {
if (fYX.c(get(intValue), interfaceC13174fSv) || sts.isDisposed()) {
return;
} else {
intValue++;
}
}
sts.a = Integer.valueOf(intValue);
i = sts.addAndGet(-i);
if (i == 0) {
return;
}
}
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public static final class ojQ extends AtomicReference<ojQ> {
final Object c;
ojQ(Object obj) {
this.c = obj;
}
}
/* loaded from: classes6.dex */
static abstract class RVV<T> extends AtomicReference<ojQ> implements jbe<T> {
int a;
private ojQ c;
final boolean d;
Object a(Object obj) {
return obj;
}
abstract void a();
Object b(Object obj) {
return obj;
}
RVV(boolean z) {
this.d = z;
ojQ ojq = new ojQ(null);
this.c = ojq;
set(ojq);
}
@Override // o.fWZ.jbe
public final void c(T t) {
ojQ ojq = new ojQ(b(fYX.d(t)));
this.c.set(ojq);
this.c = ojq;
this.a++;
a();
}
@Override // o.fWZ.jbe
public final void b(Throwable th) {
ojQ ojq = new ojQ(b(fYX.a(th)));
this.c.set(ojq);
this.c = ojq;
this.a++;
c();
}
@Override // o.fWZ.jbe
public final void d() {
ojQ ojq = new ojQ(b(fYX.c()));
this.c.set(ojq);
this.c = ojq;
this.a++;
c();
}
@Override // o.fWZ.jbe
public final void b(Sts<T> sts) {
if (sts.getAndIncrement() != 0) {
return;
}
int i = 1;
do {
ojQ ojq = (ojQ) sts.a;
if (ojq == null) {
ojq = e();
sts.a = ojq;
}
while (!sts.isDisposed()) {
ojQ ojq2 = ojq.get();
if (ojq2 != null) {
if (fYX.c(a(ojq2.c), sts.e)) {
sts.a = null;
return;
}
ojq = ojq2;
} else {
sts.a = ojq;
i = sts.addAndGet(-i);
}
}
sts.a = null;
return;
} while (i != 0);
}
ojQ e() {
return get();
}
void c() {
ojQ ojq = get();
if (ojq.c != null) {
ojQ ojq2 = new ojQ(null);
ojq2.lazySet(ojq.get());
set(ojq2);
}
}
}
/* loaded from: classes6.dex */
static final class dAO<T> extends RVV<T> {
private int c;
dAO(int i, boolean z) {
super(z);
this.c = i;
}
@Override // o.fWZ.RVV
final void a() {
if (this.a > this.c) {
ojQ ojq = get().get();
this.a--;
if (this.d) {
ojQ ojq2 = new ojQ(null);
ojq2.lazySet(ojq.get());
ojq = ojq2;
}
set(ojq);
}
}
}
/* loaded from: classes6.dex */
static final class NHB<T> extends RVV<T> {
private AbstractC13173fSu b;
private int c;
private long e;
private TimeUnit g;
NHB(int i, long j, TimeUnit timeUnit, AbstractC13173fSu abstractC13173fSu, boolean z) {
super(z);
this.b = abstractC13173fSu;
this.c = i;
this.e = j;
this.g = timeUnit;
}
@Override // o.fWZ.RVV
final Object b(Object obj) {
return new C13421fZx(obj, AbstractC13173fSu.b(this.g), this.g);
}
@Override // o.fWZ.RVV
final Object a(Object obj) {
return ((C13421fZx) obj).e;
}
@Override // o.fWZ.RVV
final void a() {
ojQ ojq;
long b = AbstractC13173fSu.b(this.g);
long j = this.e;
ojQ ojq2 = get();
ojQ ojq3 = ojq2.get();
int i = 0;
while (true) {
ojQ ojq4 = ojq3;
ojq = ojq2;
ojq2 = ojq4;
if (this.a > 1) {
if (this.a <= this.c) {
if (((C13421fZx) ojq2.c).d > b - j) {
break;
}
i++;
this.a--;
ojq3 = ojq2.get();
} else {
i++;
this.a--;
ojq3 = ojq2.get();
}
} else {
break;
}
}
if (i != 0) {
if (this.d) {
ojQ ojq5 = new ojQ(null);
ojq5.lazySet(ojq.get());
ojq = ojq5;
}
set(ojq);
}
}
@Override // o.fWZ.RVV
final void c() {
ojQ ojq;
long b = AbstractC13173fSu.b(this.g);
long j = this.e;
ojQ ojq2 = get();
ojQ ojq3 = ojq2.get();
int i = 0;
while (true) {
ojQ ojq4 = ojq3;
ojq = ojq2;
ojq2 = ojq4;
if (this.a <= 1 || ((C13421fZx) ojq2.c).d > b - j) {
break;
}
i++;
this.a--;
ojq3 = ojq2.get();
}
if (i != 0) {
if (this.d) {
ojQ ojq5 = new ojQ(null);
ojq5.lazySet(ojq.get());
ojq = ojq5;
}
set(ojq);
}
}
@Override // o.fWZ.RVV
final ojQ e() {
ojQ ojq;
long b = AbstractC13173fSu.b(this.g);
long j = this.e;
ojQ ojq2 = get();
ojQ ojq3 = ojq2.get();
while (true) {
ojQ ojq4 = ojq3;
ojq = ojq2;
ojq2 = ojq4;
if (ojq2 == null) {
break;
}
C13421fZx c13421fZx = (C13421fZx) ojq2.c;
if (fYX.e(c13421fZx.e) || fYX.b(c13421fZx.e) || c13421fZx.d > b - j) {
break;
}
ojq3 = ojq2.get();
}
return ojq;
}
}
/* loaded from: classes6.dex */
static final class jNh implements HBt<Object> {
jNh() {
}
@Override // o.fWZ.HBt
public final jbe<Object> d() {
return new ZnX();
}
}
/* loaded from: classes6.dex */
static final class LWm<R> implements fSQ<fSJ> {
private final fXV<R> d;
@Override // o.fSQ
public final /* synthetic */ void c(fSJ fsj) throws Throwable {
EnumC13192fTf.d((AtomicReference<fSJ>) this.d, fsj);
}
LWm(fXV<R> fxv) {
this.d = fxv;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public static final class ZqN<T> implements HBt<T> {
private int c;
private boolean d;
ZqN(int i, boolean z) {
this.c = i;
this.d = z;
}
@Override // o.fWZ.HBt
public final jbe<T> d() {
return new dAO(this.c, this.d);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public static final class vUG<T> implements HBt<T> {
private boolean a;
private final AbstractC13173fSu b;
private final TimeUnit c;
private final int d;
private final long e;
vUG(int i, long j, TimeUnit timeUnit, AbstractC13173fSu abstractC13173fSu, boolean z) {
this.d = i;
this.e = j;
this.c = timeUnit;
this.b = abstractC13173fSu;
this.a = z;
}
@Override // o.fWZ.HBt
public final jbe<T> d() {
return new NHB(this.d, this.e, this.c, this.b, this.a);
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public static final class saX<T> implements InterfaceC13169fSq<T> {
private final AtomicReference<tOB<T>> d;
private final HBt<T> e;
saX(AtomicReference<tOB<T>> atomicReference, HBt<T> hBt) {
this.d = atomicReference;
this.e = hBt;
}
@Override // o.InterfaceC13169fSq
public final void subscribe(InterfaceC13174fSv<? super T> interfaceC13174fSv) {
tOB<T> tob;
loop0: while (true) {
tob = this.d.get();
if (tob != null) {
break;
}
tOB<T> tob2 = new tOB<>(this.e.d(), this.d);
AtomicReference<tOB<T>> atomicReference = this.d;
while (!atomicReference.compareAndSet(null, tob2)) {
if (atomicReference.get() != null) {
break;
}
}
tob = tob2;
break loop0;
}
Sts<T> sts = new Sts<>(tob, interfaceC13174fSv);
interfaceC13174fSv.onSubscribe(sts);
loop2: while (true) {
Sts[] stsArr = tob.e.get();
if (stsArr == tOB.d) {
break;
}
int length = stsArr.length;
Sts[] stsArr2 = new Sts[length + 1];
System.arraycopy(stsArr, 0, stsArr2, 0, length);
stsArr2[length] = sts;
AtomicReference<Sts[]> atomicReference2 = tob.e;
while (!atomicReference2.compareAndSet(stsArr, stsArr2)) {
if (atomicReference2.get() != stsArr) {
break;
}
}
break loop2;
}
if (sts.isDisposed()) {
tob.b(sts);
} else {
tob.c.b(sts);
}
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public static final class IeS<R, U> extends AbstractC13163fSk<R> {
private final InterfaceC13189fTc<? extends fYZ<U>> b;
private final fSS<? super AbstractC13163fSk<U>, ? extends InterfaceC13169fSq<R>> e;
IeS(InterfaceC13189fTc<? extends fYZ<U>> interfaceC13189fTc, fSS<? super AbstractC13163fSk<U>, ? extends InterfaceC13169fSq<R>> fss) {
this.b = interfaceC13189fTc;
this.e = fss;
}
@Override // o.AbstractC13163fSk
public final void subscribeActual(InterfaceC13174fSv<? super R> interfaceC13174fSv) {
try {
fYZ fyz = (fYZ) Objects.requireNonNull(this.b.d(), "The connectableFactory returned a null ConnectableObservable");
InterfaceC13169fSq interfaceC13169fSq = (InterfaceC13169fSq) Objects.requireNonNull(this.e.a(fyz), "The selector returned a null ObservableSource");
fXV fxv = new fXV(interfaceC13174fSv);
interfaceC13169fSq.subscribe(fxv);
fyz.d(new LWm(fxv));
} catch (Throwable th) {
C13147fSI.c(th);
EnumC13195fTi.a(th, interfaceC13174fSv);
}
}
}
public static <T> fYZ<T> e(InterfaceC13169fSq<T> interfaceC13169fSq, long j, TimeUnit timeUnit, AbstractC13173fSu abstractC13173fSu, boolean z) {
vUG vug = new vUG(Integer.MAX_VALUE, j, timeUnit, abstractC13173fSu, z);
AtomicReference atomicReference = new AtomicReference();
return new fWZ(new saX(atomicReference, vug), interfaceC13169fSq, atomicReference, vug);
}
public static <T> fYZ<T> c(InterfaceC13169fSq<? extends T> interfaceC13169fSq) {
HBt hBt = d;
AtomicReference atomicReference = new AtomicReference();
return new fWZ(new saX(atomicReference, hBt), interfaceC13169fSq, atomicReference, hBt);
}
}