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

321 lines
11 KiB
Java

package o;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
/* renamed from: o.fVg, reason: case insensitive filesystem */
/* loaded from: classes6.dex */
public final class C13263fVg<T, U extends Collection<? super T>, Open, Close> extends fUX<T, U> {
private InterfaceC13169fSq<? extends Open> a;
private InterfaceC13189fTc<U> d;
private fSS<? super Open, ? extends InterfaceC13169fSq<? extends Close>> e;
public C13263fVg(InterfaceC13169fSq<T> interfaceC13169fSq, InterfaceC13169fSq<? extends Open> interfaceC13169fSq2, fSS<? super Open, ? extends InterfaceC13169fSq<? extends Close>> fss, InterfaceC13189fTc<U> interfaceC13189fTc) {
super(interfaceC13169fSq);
this.a = interfaceC13169fSq2;
this.e = fss;
this.d = interfaceC13189fTc;
}
@Override // o.AbstractC13163fSk
public final void subscribeActual(InterfaceC13174fSv<? super U> interfaceC13174fSv) {
RVV rvv = new RVV(interfaceC13174fSv, this.a, this.e, this.d);
interfaceC13174fSv.onSubscribe(rvv);
this.c.subscribe(rvv);
}
/* renamed from: o.fVg$RVV */
/* loaded from: classes6.dex */
static final class RVV<T, C extends Collection<? super T>, Open, Close> extends AtomicInteger implements InterfaceC13174fSv<T>, fSJ {
long a;
final fSS<? super Open, ? extends InterfaceC13169fSq<? extends Close>> b;
volatile boolean c;
final InterfaceC13189fTc<C> e;
private volatile boolean g;
private InterfaceC13174fSv<? super C> h;
private InterfaceC13169fSq<? extends Open> i;
private C13416fZs<C> l = new C13416fZs<>(AbstractC13163fSk.bufferSize());
final fSC f = new fSC();
final AtomicReference<fSJ> j = new AtomicReference<>();
Map<Long, C> d = new LinkedHashMap();
private C13355fYI n = new C13355fYI();
RVV(InterfaceC13174fSv<? super C> interfaceC13174fSv, InterfaceC13169fSq<? extends Open> interfaceC13169fSq, fSS<? super Open, ? extends InterfaceC13169fSq<? extends Close>> fss, InterfaceC13189fTc<C> interfaceC13189fTc) {
this.h = interfaceC13174fSv;
this.e = interfaceC13189fTc;
this.i = interfaceC13169fSq;
this.b = fss;
}
@Override // o.InterfaceC13174fSv
public final void onSubscribe(fSJ fsj) {
if (EnumC13192fTf.a(this.j, fsj)) {
HBt hBt = new HBt(this);
this.f.e(hBt);
this.i.subscribe(hBt);
}
}
@Override // o.InterfaceC13174fSv
public final void onNext(T t) {
synchronized (this) {
Map<Long, C> map = this.d;
if (map == null) {
return;
}
Iterator<C> it = map.values().iterator();
while (it.hasNext()) {
it.next().add(t);
}
}
}
@Override // o.InterfaceC13174fSv
public final void onComplete() {
this.f.dispose();
synchronized (this) {
Map<Long, C> map = this.d;
if (map == null) {
return;
}
Iterator<C> it = map.values().iterator();
while (it.hasNext()) {
this.l.b(it.next());
}
this.d = null;
this.c = true;
e();
}
}
@Override // o.fSJ
public final void dispose() {
if (EnumC13192fTf.e(this.j)) {
this.g = true;
this.f.dispose();
synchronized (this) {
this.d = null;
}
if (getAndIncrement() != 0) {
this.l.e();
}
}
}
@Override // o.fSJ
public final boolean isDisposed() {
return EnumC13192fTf.c(this.j.get());
}
final void a(HBt<T, C> hBt, long j) {
boolean z;
this.f.b(hBt);
if (this.f.e() == 0) {
EnumC13192fTf.e(this.j);
z = true;
} else {
z = false;
}
synchronized (this) {
Map<Long, C> map = this.d;
if (map == null) {
return;
}
this.l.b(map.remove(Long.valueOf(j)));
if (z) {
this.c = true;
}
e();
}
}
final void e() {
if (getAndIncrement() != 0) {
return;
}
InterfaceC13174fSv<? super C> interfaceC13174fSv = this.h;
C13416fZs<C> c13416fZs = this.l;
int i = 1;
while (!this.g) {
boolean z = this.c;
if (z && this.n.get() != null) {
c13416fZs.e();
Throwable b = fYR.b(this.n);
if (b == null) {
interfaceC13174fSv.onComplete();
return;
} else {
if (b != fYR.b) {
interfaceC13174fSv.onError(b);
return;
}
return;
}
}
C b2 = c13416fZs.b();
boolean z2 = b2 == null;
if (z && z2) {
interfaceC13174fSv.onComplete();
return;
} else if (!z2) {
interfaceC13174fSv.onNext(b2);
} else {
i = addAndGet(-i);
if (i == 0) {
return;
}
}
}
c13416fZs.e();
}
/* renamed from: o.fVg$RVV$HBt */
/* loaded from: classes6.dex */
static final class HBt<Open> extends AtomicReference<fSJ> implements InterfaceC13174fSv<Open>, fSJ {
private RVV<?, ?, Open, ?> e;
HBt(RVV<?, ?, Open, ?> rvv) {
this.e = rvv;
}
@Override // o.InterfaceC13174fSv
public final void onSubscribe(fSJ fsj) {
EnumC13192fTf.a(this, fsj);
}
@Override // o.InterfaceC13174fSv
public final void onNext(Open open) {
RVV<?, ?, Open, ?> rvv = this.e;
try {
Collection collection = (Collection) Objects.requireNonNull(rvv.e.d(), "The bufferSupplier returned a null Collection");
InterfaceC13169fSq interfaceC13169fSq = (InterfaceC13169fSq) Objects.requireNonNull(rvv.b.a(open), "The bufferClose returned a null ObservableSource");
long j = rvv.a;
rvv.a = 1 + j;
synchronized (rvv) {
Map<Long, ?> map = rvv.d;
if (map == null) {
return;
}
map.put(Long.valueOf(j), collection);
HBt hBt = new HBt(rvv, j);
rvv.f.e(hBt);
interfaceC13169fSq.subscribe(hBt);
}
} catch (Throwable th) {
C13147fSI.c(th);
EnumC13192fTf.e(rvv.j);
rvv.onError(th);
}
}
@Override // o.InterfaceC13174fSv
public final void onError(Throwable th) {
lazySet(EnumC13192fTf.DISPOSED);
RVV<?, ?, Open, ?> rvv = this.e;
EnumC13192fTf.e(rvv.j);
rvv.f.b(this);
rvv.onError(th);
}
@Override // o.InterfaceC13174fSv
public final void onComplete() {
lazySet(EnumC13192fTf.DISPOSED);
RVV<?, ?, Open, ?> rvv = this.e;
rvv.f.b(this);
if (rvv.f.e() == 0) {
EnumC13192fTf.e(rvv.j);
rvv.c = true;
rvv.e();
}
}
@Override // o.fSJ
public final void dispose() {
EnumC13192fTf.e(this);
}
@Override // o.fSJ
public final boolean isDisposed() {
return get() == EnumC13192fTf.DISPOSED;
}
}
@Override // o.InterfaceC13174fSv
public final void onError(Throwable th) {
if (fYR.c(this.n, th)) {
this.f.dispose();
synchronized (this) {
this.d = null;
}
this.c = true;
e();
return;
}
C13418fZu.c(th);
}
}
/* renamed from: o.fVg$HBt */
/* loaded from: classes6.dex */
static final class HBt<T, C extends Collection<? super T>> extends AtomicReference<fSJ> implements InterfaceC13174fSv<Object>, fSJ {
private RVV<T, C, ?, ?> b;
private long e;
HBt(RVV<T, C, ?, ?> rvv, long j) {
this.b = rvv;
this.e = j;
}
@Override // o.InterfaceC13174fSv
public final void onSubscribe(fSJ fsj) {
EnumC13192fTf.a(this, fsj);
}
@Override // o.InterfaceC13174fSv
public final void onNext(Object obj) {
fSJ fsj = get();
if (fsj != EnumC13192fTf.DISPOSED) {
lazySet(EnumC13192fTf.DISPOSED);
fsj.dispose();
this.b.a(this, this.e);
}
}
@Override // o.InterfaceC13174fSv
public final void onError(Throwable th) {
if (get() != EnumC13192fTf.DISPOSED) {
lazySet(EnumC13192fTf.DISPOSED);
RVV<T, C, ?, ?> rvv = this.b;
EnumC13192fTf.e(rvv.j);
rvv.f.b(this);
rvv.onError(th);
return;
}
C13418fZu.c(th);
}
@Override // o.InterfaceC13174fSv
public final void onComplete() {
if (get() != EnumC13192fTf.DISPOSED) {
lazySet(EnumC13192fTf.DISPOSED);
this.b.a(this, this.e);
}
}
@Override // o.fSJ
public final void dispose() {
EnumC13192fTf.e(this);
}
@Override // o.fSJ
public final boolean isDisposed() {
return get() == EnumC13192fTf.DISPOSED;
}
}
}