221 lines
6.6 KiB
Java
221 lines
6.6 KiB
Java
package o;
|
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
/* loaded from: classes6.dex */
|
|
public final class fWI<T> extends fYZ<T> {
|
|
private AtomicReference<LWm<T>> b = new AtomicReference<>();
|
|
private InterfaceC13169fSq<T> e;
|
|
|
|
public fWI(InterfaceC13169fSq<T> interfaceC13169fSq) {
|
|
this.e = interfaceC13169fSq;
|
|
}
|
|
|
|
@Override // o.fYZ
|
|
public final void d(fSQ<? super fSJ> fsq) {
|
|
LWm<T> lWm;
|
|
loop0: while (true) {
|
|
lWm = this.b.get();
|
|
if (lWm != null && !lWm.isDisposed()) {
|
|
break;
|
|
}
|
|
LWm<T> lWm2 = new LWm<>(this.b);
|
|
AtomicReference<LWm<T>> atomicReference = this.b;
|
|
while (!atomicReference.compareAndSet(lWm, lWm2)) {
|
|
if (atomicReference.get() != lWm) {
|
|
break;
|
|
}
|
|
}
|
|
lWm = lWm2;
|
|
break loop0;
|
|
}
|
|
boolean z = false;
|
|
if (!lWm.a.get() && lWm.a.compareAndSet(false, true)) {
|
|
z = true;
|
|
}
|
|
try {
|
|
fsq.c(lWm);
|
|
if (z) {
|
|
this.e.subscribe(lWm);
|
|
}
|
|
} catch (Throwable th) {
|
|
C13147fSI.c(th);
|
|
throw fYR.c(th);
|
|
}
|
|
}
|
|
|
|
@Override // o.AbstractC13163fSk
|
|
public final void subscribeActual(InterfaceC13174fSv<? super T> interfaceC13174fSv) {
|
|
LWm<T> lWm;
|
|
Sts<T>[] stsArr;
|
|
Sts[] stsArr2;
|
|
loop0: while (true) {
|
|
lWm = this.b.get();
|
|
if (lWm != null) {
|
|
break;
|
|
}
|
|
LWm<T> lWm2 = new LWm<>(this.b);
|
|
AtomicReference<LWm<T>> atomicReference = this.b;
|
|
while (!atomicReference.compareAndSet(lWm, lWm2)) {
|
|
if (atomicReference.get() != lWm) {
|
|
break;
|
|
}
|
|
}
|
|
lWm = lWm2;
|
|
break loop0;
|
|
}
|
|
Sts<T> sts = new Sts<>(interfaceC13174fSv, lWm);
|
|
interfaceC13174fSv.onSubscribe(sts);
|
|
do {
|
|
stsArr = lWm.get();
|
|
if (stsArr == LWm.e) {
|
|
Throwable th = lWm.b;
|
|
if (th != null) {
|
|
interfaceC13174fSv.onError(th);
|
|
return;
|
|
} else {
|
|
interfaceC13174fSv.onComplete();
|
|
return;
|
|
}
|
|
}
|
|
int length = stsArr.length;
|
|
stsArr2 = new Sts[length + 1];
|
|
System.arraycopy(stsArr, 0, stsArr2, 0, length);
|
|
stsArr2[length] = sts;
|
|
} while (!lWm.compareAndSet(stsArr, stsArr2));
|
|
if (sts.isDisposed()) {
|
|
lWm.e(sts);
|
|
}
|
|
}
|
|
|
|
@Override // o.fYZ
|
|
public final void d() {
|
|
LWm<T> lWm = this.b.get();
|
|
if (lWm == null || !lWm.isDisposed()) {
|
|
return;
|
|
}
|
|
AtomicReference<LWm<T>> atomicReference = this.b;
|
|
while (!atomicReference.compareAndSet(lWm, null) && atomicReference.get() == lWm) {
|
|
}
|
|
}
|
|
|
|
/* loaded from: classes6.dex */
|
|
static final class LWm<T> extends AtomicReference<Sts<T>[]> implements InterfaceC13174fSv<T>, fSJ {
|
|
private static Sts[] c = new Sts[0];
|
|
static final Sts[] e = new Sts[0];
|
|
Throwable b;
|
|
private AtomicReference<LWm<T>> d;
|
|
final AtomicBoolean a = new AtomicBoolean();
|
|
private AtomicReference<fSJ> h = new AtomicReference<>();
|
|
|
|
LWm(AtomicReference<LWm<T>> atomicReference) {
|
|
this.d = atomicReference;
|
|
lazySet(c);
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final void dispose() {
|
|
getAndSet(e);
|
|
AtomicReference<LWm<T>> atomicReference = this.d;
|
|
while (!atomicReference.compareAndSet(this, null) && atomicReference.get() == this) {
|
|
}
|
|
EnumC13192fTf.e(this.h);
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final boolean isDisposed() {
|
|
return get() == e;
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onSubscribe(fSJ fsj) {
|
|
EnumC13192fTf.a(this.h, fsj);
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onNext(T t) {
|
|
for (Sts<T> sts : get()) {
|
|
sts.b.onNext(t);
|
|
}
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onError(Throwable th) {
|
|
if (this.h.get() != EnumC13192fTf.DISPOSED) {
|
|
this.b = th;
|
|
this.h.lazySet(EnumC13192fTf.DISPOSED);
|
|
for (Sts<T> sts : getAndSet(e)) {
|
|
sts.b.onError(th);
|
|
}
|
|
return;
|
|
}
|
|
C13418fZu.c(th);
|
|
}
|
|
|
|
@Override // o.InterfaceC13174fSv
|
|
public final void onComplete() {
|
|
this.h.lazySet(EnumC13192fTf.DISPOSED);
|
|
for (Sts<T> sts : getAndSet(e)) {
|
|
sts.b.onComplete();
|
|
}
|
|
}
|
|
|
|
public final void e(Sts<T> sts) {
|
|
Sts<T>[] stsArr;
|
|
Sts[] stsArr2;
|
|
do {
|
|
stsArr = get();
|
|
int length = stsArr.length;
|
|
if (length == 0) {
|
|
return;
|
|
}
|
|
int i = 0;
|
|
while (true) {
|
|
if (i >= length) {
|
|
i = -1;
|
|
break;
|
|
} else if (stsArr[i] == sts) {
|
|
break;
|
|
} else {
|
|
i++;
|
|
}
|
|
}
|
|
if (i < 0) {
|
|
return;
|
|
}
|
|
stsArr2 = c;
|
|
if (length != 1) {
|
|
stsArr2 = new Sts[length - 1];
|
|
System.arraycopy(stsArr, 0, stsArr2, 0, i);
|
|
System.arraycopy(stsArr, i + 1, stsArr2, i, (length - i) - 1);
|
|
}
|
|
} while (!compareAndSet(stsArr, stsArr2));
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* loaded from: classes6.dex */
|
|
public static final class Sts<T> extends AtomicReference<LWm<T>> implements fSJ {
|
|
final InterfaceC13174fSv<? super T> b;
|
|
|
|
Sts(InterfaceC13174fSv<? super T> interfaceC13174fSv, LWm<T> lWm) {
|
|
this.b = interfaceC13174fSv;
|
|
lazySet(lWm);
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final void dispose() {
|
|
LWm<T> andSet = getAndSet(null);
|
|
if (andSet != null) {
|
|
andSet.e(this);
|
|
}
|
|
}
|
|
|
|
@Override // o.fSJ
|
|
public final boolean isDisposed() {
|
|
return get() == null;
|
|
}
|
|
}
|
|
}
|