314 lines
10 KiB
Java
314 lines
10 KiB
Java
|
package o;
|
||
|
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.Map;
|
||
|
import java.util.Objects;
|
||
|
import java.util.concurrent.ConcurrentHashMap;
|
||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||
|
import java.util.concurrent.atomic.AtomicReference;
|
||
|
|
||
|
/* renamed from: o.fWo, reason: case insensitive filesystem */
|
||
|
/* loaded from: classes6.dex */
|
||
|
public final class C13306fWo<T, K, V> extends fUX<T, AbstractC13399fZb<K, V>> {
|
||
|
private fSS<? super T, ? extends K> a;
|
||
|
private int b;
|
||
|
private boolean d;
|
||
|
private fSS<? super T, ? extends V> e;
|
||
|
|
||
|
public C13306fWo(InterfaceC13169fSq<T> interfaceC13169fSq, fSS<? super T, ? extends K> fss, fSS<? super T, ? extends V> fss2, int i, boolean z) {
|
||
|
super(interfaceC13169fSq);
|
||
|
this.a = fss;
|
||
|
this.e = fss2;
|
||
|
this.b = i;
|
||
|
this.d = z;
|
||
|
}
|
||
|
|
||
|
@Override // o.AbstractC13163fSk
|
||
|
public final void subscribeActual(InterfaceC13174fSv<? super AbstractC13399fZb<K, V>> interfaceC13174fSv) {
|
||
|
this.c.subscribe(new HBt(interfaceC13174fSv, this.a, this.e, this.b, this.d));
|
||
|
}
|
||
|
|
||
|
/* renamed from: o.fWo$HBt */
|
||
|
/* loaded from: classes6.dex */
|
||
|
public static final class HBt<T, K, V> extends AtomicInteger implements InterfaceC13174fSv<T>, fSJ {
|
||
|
private static Object e = new Object();
|
||
|
private InterfaceC13174fSv<? super AbstractC13399fZb<K, V>> a;
|
||
|
private boolean b;
|
||
|
private int d;
|
||
|
private fSS<? super T, ? extends K> f;
|
||
|
private fSS<? super T, ? extends V> g;
|
||
|
private fSJ i;
|
||
|
private AtomicBoolean c = new AtomicBoolean();
|
||
|
private Map<Object, IeS<K, V>> j = new ConcurrentHashMap();
|
||
|
|
||
|
public HBt(InterfaceC13174fSv<? super AbstractC13399fZb<K, V>> interfaceC13174fSv, fSS<? super T, ? extends K> fss, fSS<? super T, ? extends V> fss2, int i, boolean z) {
|
||
|
this.a = interfaceC13174fSv;
|
||
|
this.f = fss;
|
||
|
this.g = fss2;
|
||
|
this.d = i;
|
||
|
this.b = z;
|
||
|
lazySet(1);
|
||
|
}
|
||
|
|
||
|
@Override // o.InterfaceC13174fSv
|
||
|
public final void onSubscribe(fSJ fsj) {
|
||
|
if (EnumC13192fTf.d(this.i, fsj)) {
|
||
|
this.i = fsj;
|
||
|
this.a.onSubscribe(this);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // o.InterfaceC13174fSv
|
||
|
public final void onNext(T t) {
|
||
|
boolean z;
|
||
|
try {
|
||
|
K a = this.f.a(t);
|
||
|
Object obj = a != null ? a : e;
|
||
|
IeS<K, V> ieS = this.j.get(obj);
|
||
|
if (ieS != null) {
|
||
|
z = false;
|
||
|
} else {
|
||
|
if (this.c.get()) {
|
||
|
return;
|
||
|
}
|
||
|
ieS = IeS.b(a, this.d, this, this.b);
|
||
|
this.j.put(obj, ieS);
|
||
|
getAndIncrement();
|
||
|
z = true;
|
||
|
}
|
||
|
try {
|
||
|
Object requireNonNull = Objects.requireNonNull(this.g.a(t), "The value supplied is null");
|
||
|
RVV<V, K> rvv = ieS.c;
|
||
|
rvv.a.b(requireNonNull);
|
||
|
rvv.c();
|
||
|
if (z) {
|
||
|
this.a.onNext(ieS);
|
||
|
RVV<V, K> rvv2 = ieS.c;
|
||
|
if (rvv2.e.get() == 0 && rvv2.e.compareAndSet(0, 2)) {
|
||
|
d(a);
|
||
|
RVV<V, K> rvv3 = ieS.c;
|
||
|
rvv3.c = true;
|
||
|
rvv3.c();
|
||
|
}
|
||
|
}
|
||
|
} catch (Throwable th) {
|
||
|
C13147fSI.c(th);
|
||
|
this.i.dispose();
|
||
|
if (z) {
|
||
|
this.a.onNext(ieS);
|
||
|
}
|
||
|
onError(th);
|
||
|
}
|
||
|
} catch (Throwable th2) {
|
||
|
C13147fSI.c(th2);
|
||
|
this.i.dispose();
|
||
|
onError(th2);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // o.InterfaceC13174fSv
|
||
|
public final void onError(Throwable th) {
|
||
|
ArrayList arrayList = new ArrayList(this.j.values());
|
||
|
this.j.clear();
|
||
|
Iterator it = arrayList.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
RVV<T, K> rvv = ((IeS) it.next()).c;
|
||
|
rvv.d = th;
|
||
|
rvv.c = true;
|
||
|
rvv.c();
|
||
|
}
|
||
|
this.a.onError(th);
|
||
|
}
|
||
|
|
||
|
@Override // o.InterfaceC13174fSv
|
||
|
public final void onComplete() {
|
||
|
ArrayList arrayList = new ArrayList(this.j.values());
|
||
|
this.j.clear();
|
||
|
Iterator it = arrayList.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
RVV<T, K> rvv = ((IeS) it.next()).c;
|
||
|
rvv.c = true;
|
||
|
rvv.c();
|
||
|
}
|
||
|
this.a.onComplete();
|
||
|
}
|
||
|
|
||
|
@Override // o.fSJ
|
||
|
public final void dispose() {
|
||
|
if (this.c.compareAndSet(false, true) && decrementAndGet() == 0) {
|
||
|
this.i.dispose();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // o.fSJ
|
||
|
public final boolean isDisposed() {
|
||
|
return this.c.get();
|
||
|
}
|
||
|
|
||
|
public final void d(K k) {
|
||
|
if (k == null) {
|
||
|
k = (K) e;
|
||
|
}
|
||
|
this.j.remove(k);
|
||
|
if (decrementAndGet() == 0) {
|
||
|
this.i.dispose();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* renamed from: o.fWo$IeS */
|
||
|
/* loaded from: classes6.dex */
|
||
|
public static final class IeS<K, T> extends AbstractC13399fZb<K, T> {
|
||
|
final RVV<T, K> c;
|
||
|
|
||
|
public static <T, K> IeS<K, T> b(K k, int i, HBt<?, K, T> hBt, boolean z) {
|
||
|
return new IeS<>(k, new RVV(i, hBt, k, z));
|
||
|
}
|
||
|
|
||
|
private IeS(K k, RVV<T, K> rvv) {
|
||
|
super(k);
|
||
|
this.c = rvv;
|
||
|
}
|
||
|
|
||
|
@Override // o.AbstractC13163fSk
|
||
|
public final void subscribeActual(InterfaceC13174fSv<? super T> interfaceC13174fSv) {
|
||
|
this.c.subscribe(interfaceC13174fSv);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* renamed from: o.fWo$RVV */
|
||
|
/* loaded from: classes6.dex */
|
||
|
public static final class RVV<T, K> extends AtomicInteger implements fSJ, InterfaceC13169fSq<T> {
|
||
|
final C13416fZs<T> a;
|
||
|
volatile boolean c;
|
||
|
Throwable d;
|
||
|
private boolean f;
|
||
|
private HBt<?, K, T> h;
|
||
|
private K i;
|
||
|
private AtomicBoolean g = new AtomicBoolean();
|
||
|
private AtomicReference<InterfaceC13174fSv<? super T>> b = new AtomicReference<>();
|
||
|
final AtomicInteger e = new AtomicInteger();
|
||
|
|
||
|
RVV(int i, HBt<?, K, T> hBt, K k, boolean z) {
|
||
|
this.a = new C13416fZs<>(i);
|
||
|
this.h = hBt;
|
||
|
this.i = k;
|
||
|
this.f = z;
|
||
|
}
|
||
|
|
||
|
@Override // o.fSJ
|
||
|
public final void dispose() {
|
||
|
if (this.g.compareAndSet(false, true) && getAndIncrement() == 0) {
|
||
|
this.b.lazySet(null);
|
||
|
if ((this.e.get() & 2) == 0) {
|
||
|
this.h.d(this.i);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // o.fSJ
|
||
|
public final boolean isDisposed() {
|
||
|
return this.g.get();
|
||
|
}
|
||
|
|
||
|
@Override // o.InterfaceC13169fSq
|
||
|
public final void subscribe(InterfaceC13174fSv<? super T> interfaceC13174fSv) {
|
||
|
int i;
|
||
|
do {
|
||
|
i = this.e.get();
|
||
|
if ((i & 1) != 0) {
|
||
|
EnumC13195fTi.a(new IllegalStateException("Only one Observer allowed!"), interfaceC13174fSv);
|
||
|
return;
|
||
|
}
|
||
|
} while (!this.e.compareAndSet(i, i | 1));
|
||
|
interfaceC13174fSv.onSubscribe(this);
|
||
|
this.b.lazySet(interfaceC13174fSv);
|
||
|
if (this.g.get()) {
|
||
|
this.b.lazySet(null);
|
||
|
} else {
|
||
|
c();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
final void c() {
|
||
|
if (getAndIncrement() != 0) {
|
||
|
return;
|
||
|
}
|
||
|
C13416fZs<T> c13416fZs = this.a;
|
||
|
boolean z = this.f;
|
||
|
InterfaceC13174fSv<? super T> interfaceC13174fSv = this.b.get();
|
||
|
int i = 1;
|
||
|
while (true) {
|
||
|
if (interfaceC13174fSv != null) {
|
||
|
while (true) {
|
||
|
boolean z2 = this.c;
|
||
|
T b = c13416fZs.b();
|
||
|
boolean z3 = b == null;
|
||
|
if (!a(z2, z3, interfaceC13174fSv, z)) {
|
||
|
if (z3) {
|
||
|
break;
|
||
|
} else {
|
||
|
interfaceC13174fSv.onNext(b);
|
||
|
}
|
||
|
} else {
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
i = addAndGet(-i);
|
||
|
if (i == 0) {
|
||
|
return;
|
||
|
}
|
||
|
if (interfaceC13174fSv == null) {
|
||
|
interfaceC13174fSv = this.b.get();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private boolean a(boolean z, boolean z2, InterfaceC13174fSv<? super T> interfaceC13174fSv, boolean z3) {
|
||
|
if (this.g.get()) {
|
||
|
this.a.e();
|
||
|
this.b.lazySet(null);
|
||
|
if ((this.e.get() & 2) == 0) {
|
||
|
this.h.d(this.i);
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
if (!z) {
|
||
|
return false;
|
||
|
}
|
||
|
if (z3) {
|
||
|
if (!z2) {
|
||
|
return false;
|
||
|
}
|
||
|
Throwable th = this.d;
|
||
|
this.b.lazySet(null);
|
||
|
if (th != null) {
|
||
|
interfaceC13174fSv.onError(th);
|
||
|
} else {
|
||
|
interfaceC13174fSv.onComplete();
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
Throwable th2 = this.d;
|
||
|
if (th2 != null) {
|
||
|
this.a.e();
|
||
|
this.b.lazySet(null);
|
||
|
interfaceC13174fSv.onError(th2);
|
||
|
return true;
|
||
|
}
|
||
|
if (!z2) {
|
||
|
return false;
|
||
|
}
|
||
|
this.b.lazySet(null);
|
||
|
interfaceC13174fSv.onComplete();
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
}
|