258 lines
7.2 KiB
Java
258 lines
7.2 KiB
Java
package o;
|
|
|
|
import java.util.Objects;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
/* renamed from: o.fZz, reason: case insensitive filesystem */
|
|
/* loaded from: classes6.dex */
|
|
public final class C13423fZz<T> extends AbstractC13422fZy<T> {
|
|
boolean b;
|
|
volatile boolean c;
|
|
final C13416fZs<T> e;
|
|
private volatile boolean f;
|
|
private Throwable g;
|
|
private AtomicReference<Runnable> i;
|
|
private boolean j = true;
|
|
final AtomicReference<InterfaceC13174fSv<? super T>> d = new AtomicReference<>();
|
|
private AtomicBoolean h = new AtomicBoolean();
|
|
final AbstractC13183fTH<T> a = new LWm(this);
|
|
|
|
public static <T> C13423fZz<T> c() {
|
|
return new C13423fZz<>(bufferSize(), null);
|
|
}
|
|
|
|
public static <T> C13423fZz<T> b(int i, Runnable runnable) {
|
|
C13199fTm.c(i, "capacityHint");
|
|
Objects.requireNonNull(runnable, "onTerminate");
|
|
return new C13423fZz<>(i, runnable);
|
|
}
|
|
|
|
private C13423fZz(int i, Runnable runnable) {
|
|
this.e = new C13416fZs<>(i);
|
|
this.i = new AtomicReference<>(runnable);
|
|
}
|
|
|
|
@Override // o.AbstractC13163fSk
|
|
public final void subscribeActual(InterfaceC13174fSv<? super T> interfaceC13174fSv) {
|
|
if (!this.h.get() && this.h.compareAndSet(false, true)) {
|
|
interfaceC13174fSv.onSubscribe(this.a);
|
|
this.d.lazySet(interfaceC13174fSv);
|
|
if (this.c) {
|
|
this.d.lazySet(null);
|
|
return;
|
|
} else {
|
|
d();
|
|
return;
|
|
}
|
|
}
|
|
EnumC13195fTi.a(new IllegalStateException("Only a single observer allowed."), interfaceC13174fSv);
|
|
}
|
|
|
|
final void b() {
|
|
Runnable runnable = this.i.get();
|
|
if (runnable != null) {
|
|
AtomicReference<Runnable> atomicReference = this.i;
|
|
while (!atomicReference.compareAndSet(runnable, null)) {
|
|
if (atomicReference.get() != runnable) {
|
|
return;
|
|
}
|
|
}
|
|
runnable.run();
|
|
}
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onSubscribe(fSJ fsj) {
|
|
if (this.f || this.c) {
|
|
fsj.dispose();
|
|
}
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onNext(T t) {
|
|
fYR.d(t, "onNext called with a null value.");
|
|
if (this.f || this.c) {
|
|
return;
|
|
}
|
|
this.e.b(t);
|
|
d();
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onError(Throwable th) {
|
|
fYR.d(th, "onError called with a null Throwable.");
|
|
if (this.f || this.c) {
|
|
C13418fZu.c(th);
|
|
return;
|
|
}
|
|
this.g = th;
|
|
this.f = true;
|
|
b();
|
|
d();
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onComplete() {
|
|
if (this.f || this.c) {
|
|
return;
|
|
}
|
|
this.f = true;
|
|
b();
|
|
d();
|
|
}
|
|
|
|
private boolean a(InterfaceC13414fZq<T> interfaceC13414fZq, InterfaceC13174fSv<? super T> interfaceC13174fSv) {
|
|
Throwable th = this.g;
|
|
if (th == null) {
|
|
return false;
|
|
}
|
|
this.d.lazySet(null);
|
|
interfaceC13414fZq.e();
|
|
interfaceC13174fSv.onError(th);
|
|
return true;
|
|
}
|
|
|
|
private void d() {
|
|
if (this.a.getAndIncrement() != 0) {
|
|
return;
|
|
}
|
|
InterfaceC13174fSv<? super T> interfaceC13174fSv = this.d.get();
|
|
int i = 1;
|
|
while (interfaceC13174fSv == null) {
|
|
i = this.a.addAndGet(-i);
|
|
if (i == 0) {
|
|
return;
|
|
} else {
|
|
interfaceC13174fSv = this.d.get();
|
|
}
|
|
}
|
|
if (this.b) {
|
|
C13416fZs<T> c13416fZs = this.e;
|
|
boolean z = this.j;
|
|
int i2 = 1;
|
|
while (!this.c) {
|
|
boolean z2 = this.f;
|
|
if ((!z) && z2 && a(c13416fZs, interfaceC13174fSv)) {
|
|
return;
|
|
}
|
|
interfaceC13174fSv.onNext(null);
|
|
if (!z2) {
|
|
i2 = this.a.addAndGet(-i2);
|
|
if (i2 == 0) {
|
|
return;
|
|
}
|
|
} else {
|
|
this.d.lazySet(null);
|
|
Throwable th = this.g;
|
|
if (th != null) {
|
|
interfaceC13174fSv.onError(th);
|
|
return;
|
|
} else {
|
|
interfaceC13174fSv.onComplete();
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
this.d.lazySet(null);
|
|
return;
|
|
}
|
|
C13416fZs<T> c13416fZs2 = this.e;
|
|
boolean z3 = this.j;
|
|
boolean z4 = true;
|
|
int i3 = 1;
|
|
while (!this.c) {
|
|
boolean z5 = this.f;
|
|
T b = this.e.b();
|
|
boolean z6 = b == null;
|
|
if (z5) {
|
|
if ((!z3) && z4) {
|
|
if (a(c13416fZs2, interfaceC13174fSv)) {
|
|
return;
|
|
} else {
|
|
z4 = false;
|
|
}
|
|
}
|
|
if (z6) {
|
|
this.d.lazySet(null);
|
|
Throwable th2 = this.g;
|
|
if (th2 != null) {
|
|
interfaceC13174fSv.onError(th2);
|
|
return;
|
|
} else {
|
|
interfaceC13174fSv.onComplete();
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
if (!z6) {
|
|
interfaceC13174fSv.onNext(b);
|
|
} else {
|
|
i3 = this.a.addAndGet(-i3);
|
|
if (i3 == 0) {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
this.d.lazySet(null);
|
|
c13416fZs2.e();
|
|
}
|
|
|
|
/* renamed from: o.fZz$LWm */
|
|
/* loaded from: classes6.dex */
|
|
final class LWm extends AbstractC13183fTH<T> {
|
|
private C13423fZz d;
|
|
|
|
LWm(C13423fZz c13423fZz) {
|
|
this.d = c13423fZz;
|
|
}
|
|
|
|
@Override // o.InterfaceC13413fZp
|
|
public final int b(int i) {
|
|
if ((i & 2) == 0) {
|
|
return 0;
|
|
}
|
|
this.d.b = true;
|
|
return 2;
|
|
}
|
|
|
|
@Override // o.InterfaceC13414fZq
|
|
public final T b() {
|
|
return this.d.e.b();
|
|
}
|
|
|
|
@Override // o.InterfaceC13414fZq
|
|
public final boolean c() {
|
|
C13416fZs<T> c13416fZs = this.d.e;
|
|
return c13416fZs.b.get() == c13416fZs.e.get();
|
|
}
|
|
|
|
@Override // o.InterfaceC13414fZq
|
|
public final void e() {
|
|
this.d.e.e();
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final void dispose() {
|
|
if (this.d.c) {
|
|
return;
|
|
}
|
|
this.d.c = true;
|
|
this.d.b();
|
|
this.d.d.lazySet(null);
|
|
if (this.d.a.getAndIncrement() == 0) {
|
|
this.d.d.lazySet(null);
|
|
if (this.d.b) {
|
|
return;
|
|
}
|
|
this.d.e.e();
|
|
}
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final boolean isDisposed() {
|
|
return this.d.c;
|
|
}
|
|
}
|
|
}
|