2021-11-08 18:25:28 +00:00
|
|
|
package j0.l.a;
|
2021-06-27 20:44:35 +00:00
|
|
|
|
2021-08-09 22:50:01 +00:00
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
2022-01-27 00:50:41 +00:00
|
|
|
import b.i.a.f.e.o.f;
|
2021-11-08 18:25:28 +00:00
|
|
|
import j0.l.a.e;
|
2021-12-17 22:03:14 +00:00
|
|
|
import j0.l.e.i;
|
|
|
|
import j0.l.e.n.c;
|
|
|
|
import j0.l.e.o.n;
|
|
|
|
import j0.l.e.o.y;
|
2021-06-27 20:44:35 +00:00
|
|
|
import java.util.Queue;
|
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
|
import java.util.concurrent.atomic.AtomicLong;
|
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
import rx.Observable;
|
|
|
|
import rx.Producer;
|
|
|
|
import rx.Subscriber;
|
|
|
|
import rx.Subscription;
|
|
|
|
import rx.exceptions.MissingBackpressureException;
|
|
|
|
import rx.functions.Action1;
|
|
|
|
/* compiled from: OperatorPublish */
|
2021-11-08 18:25:28 +00:00
|
|
|
public final class h1<T> extends j0.m.b<T> {
|
2021-12-17 22:03:14 +00:00
|
|
|
public final Observable<? extends T> k;
|
|
|
|
public final AtomicReference<b<T>> l;
|
2021-06-27 20:44:35 +00:00
|
|
|
|
|
|
|
/* compiled from: OperatorPublish */
|
|
|
|
public static final class a<T> extends AtomicLong implements Producer, Subscription {
|
|
|
|
private static final long serialVersionUID = -4453897557930727610L;
|
|
|
|
public final Subscriber<? super T> child;
|
|
|
|
public final b<T> parent;
|
|
|
|
|
|
|
|
public a(b<T> bVar, Subscriber<? super T> subscriber) {
|
|
|
|
this.parent = bVar;
|
|
|
|
this.child = subscriber;
|
|
|
|
lazySet(-4611686018427387904L);
|
|
|
|
}
|
|
|
|
|
|
|
|
public long a(long j) {
|
|
|
|
long j2;
|
|
|
|
long j3;
|
|
|
|
if (j > 0) {
|
|
|
|
do {
|
|
|
|
j2 = get();
|
|
|
|
if (j2 == -4611686018427387904L) {
|
|
|
|
throw new IllegalStateException("Produced without request");
|
|
|
|
} else if (j2 == Long.MIN_VALUE) {
|
|
|
|
return Long.MIN_VALUE;
|
|
|
|
} else {
|
|
|
|
j3 = j2 - j;
|
|
|
|
if (j3 < 0) {
|
2021-11-08 18:25:28 +00:00
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
sb.append("More produced (");
|
|
|
|
sb.append(j);
|
|
|
|
sb.append(") than requested (");
|
2021-12-21 23:37:30 +00:00
|
|
|
throw new IllegalStateException(b.d.b.a.a.B(sb, j2, ")"));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (!compareAndSet(j2, j3));
|
|
|
|
return j3;
|
|
|
|
}
|
|
|
|
throw new IllegalArgumentException("Cant produce zero or less");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // rx.Subscription
|
|
|
|
public boolean isUnsubscribed() {
|
|
|
|
return get() == Long.MIN_VALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // rx.Producer
|
|
|
|
public void j(long j) {
|
|
|
|
long j2;
|
|
|
|
long j3;
|
|
|
|
int i = (j > 0 ? 1 : (j == 0 ? 0 : -1));
|
|
|
|
if (i >= 0) {
|
|
|
|
do {
|
|
|
|
j2 = get();
|
|
|
|
if (j2 != Long.MIN_VALUE) {
|
|
|
|
if (j2 >= 0 && i == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (j2 == -4611686018427387904L) {
|
|
|
|
j3 = j;
|
|
|
|
} else {
|
|
|
|
j3 = j2 + j;
|
|
|
|
if (j3 < 0) {
|
2021-08-09 22:50:01 +00:00
|
|
|
j3 = RecyclerView.FOREVER_NS;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} while (!compareAndSet(j2, j3));
|
|
|
|
this.parent.b();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // rx.Subscription
|
|
|
|
public void unsubscribe() {
|
|
|
|
a[] aVarArr;
|
|
|
|
a[] aVarArr2;
|
|
|
|
if (get() != Long.MIN_VALUE && getAndSet(Long.MIN_VALUE) != Long.MIN_VALUE) {
|
|
|
|
b<T> bVar = this.parent;
|
|
|
|
do {
|
2021-12-17 22:03:14 +00:00
|
|
|
aVarArr = bVar.o.get();
|
|
|
|
if (aVarArr != b.j && aVarArr != b.k) {
|
2021-06-27 20:44:35 +00:00
|
|
|
int length = aVarArr.length;
|
|
|
|
int i = 0;
|
|
|
|
while (true) {
|
|
|
|
if (i >= length) {
|
|
|
|
i = -1;
|
|
|
|
break;
|
|
|
|
} else if (aVarArr[i].equals(this)) {
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i < 0) {
|
|
|
|
break;
|
|
|
|
} else if (length == 1) {
|
2021-12-17 22:03:14 +00:00
|
|
|
aVarArr2 = b.j;
|
2021-06-27 20:44:35 +00:00
|
|
|
} else {
|
|
|
|
a[] aVarArr3 = new a[(length - 1)];
|
|
|
|
System.arraycopy(aVarArr, 0, aVarArr3, 0, i);
|
|
|
|
System.arraycopy(aVarArr, i + 1, aVarArr3, i, (length - i) - 1);
|
|
|
|
aVarArr2 = aVarArr3;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
2021-12-17 22:03:14 +00:00
|
|
|
} while (!bVar.o.compareAndSet(aVarArr, aVarArr2));
|
2021-06-27 20:44:35 +00:00
|
|
|
this.parent.b();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: OperatorPublish */
|
|
|
|
public static final class b<T> extends Subscriber<T> implements Subscription {
|
|
|
|
public static final a[] j = new a[0];
|
2021-12-17 22:03:14 +00:00
|
|
|
public static final a[] k = new a[0];
|
|
|
|
public final Queue<Object> l;
|
|
|
|
public final AtomicReference<b<T>> m;
|
|
|
|
public volatile Object n;
|
|
|
|
public final AtomicReference<a[]> o;
|
|
|
|
public final AtomicBoolean p;
|
2021-06-27 20:44:35 +00:00
|
|
|
public boolean q;
|
2021-12-17 22:03:14 +00:00
|
|
|
public boolean r;
|
2021-06-27 20:44:35 +00:00
|
|
|
|
|
|
|
public b(AtomicReference<b<T>> atomicReference) {
|
2021-12-17 22:03:14 +00:00
|
|
|
this.l = y.b() ? new n<>(i.j) : new c<>(i.j);
|
|
|
|
this.o = new AtomicReference<>(j);
|
|
|
|
this.m = atomicReference;
|
|
|
|
this.p = new AtomicBoolean();
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean a(Object obj, boolean z2) {
|
2021-12-17 22:03:14 +00:00
|
|
|
int i = 0;
|
2021-06-27 20:44:35 +00:00
|
|
|
if (obj != null) {
|
|
|
|
if (!e.c(obj)) {
|
|
|
|
Throwable th = ((e.c) obj).e;
|
2021-12-17 22:03:14 +00:00
|
|
|
this.m.compareAndSet(this, null);
|
2021-06-27 20:44:35 +00:00
|
|
|
try {
|
2021-12-17 22:03:14 +00:00
|
|
|
a[] andSet = this.o.getAndSet(k);
|
2021-06-27 20:44:35 +00:00
|
|
|
int length = andSet.length;
|
2021-12-17 22:03:14 +00:00
|
|
|
while (i < length) {
|
|
|
|
andSet[i].child.onError(th);
|
|
|
|
i++;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
} finally {
|
|
|
|
unsubscribe();
|
|
|
|
}
|
|
|
|
} else if (z2) {
|
2021-12-17 22:03:14 +00:00
|
|
|
this.m.compareAndSet(this, null);
|
2021-06-27 20:44:35 +00:00
|
|
|
try {
|
2021-12-17 22:03:14 +00:00
|
|
|
a[] andSet2 = this.o.getAndSet(k);
|
2021-06-27 20:44:35 +00:00
|
|
|
int length2 = andSet2.length;
|
2021-12-17 22:03:14 +00:00
|
|
|
while (i < length2) {
|
|
|
|
andSet2[i].child.onCompleted();
|
|
|
|
i++;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
} finally {
|
|
|
|
unsubscribe();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:63:0x00c3, code lost:
|
|
|
|
if (r4 == false) goto L_0x00d5;
|
|
|
|
*/
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:83:0x00dc, code lost:
|
|
|
|
r0 = th;
|
|
|
|
*/
|
|
|
|
public void b() {
|
|
|
|
boolean z2;
|
|
|
|
Throwable th;
|
|
|
|
long j2;
|
|
|
|
synchronized (this) {
|
2021-12-17 22:03:14 +00:00
|
|
|
if (this.q) {
|
|
|
|
this.r = true;
|
2021-06-27 20:44:35 +00:00
|
|
|
return;
|
|
|
|
} else {
|
2021-12-17 22:03:14 +00:00
|
|
|
this.q = true;
|
|
|
|
this.r = false;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
while (true) {
|
|
|
|
try {
|
2021-12-17 22:03:14 +00:00
|
|
|
Object obj = this.n;
|
|
|
|
boolean isEmpty = this.l.isEmpty();
|
2021-06-27 20:44:35 +00:00
|
|
|
if (!a(obj, isEmpty)) {
|
|
|
|
if (!isEmpty) {
|
2021-12-17 22:03:14 +00:00
|
|
|
a[] aVarArr = this.o.get();
|
2021-06-27 20:44:35 +00:00
|
|
|
int length = aVarArr.length;
|
2021-08-09 22:50:01 +00:00
|
|
|
long j3 = RecyclerView.FOREVER_NS;
|
2021-12-17 22:03:14 +00:00
|
|
|
int i = 0;
|
2021-06-27 20:44:35 +00:00
|
|
|
for (a aVar : aVarArr) {
|
|
|
|
long j4 = aVar.get();
|
|
|
|
if (j4 >= 0) {
|
|
|
|
j3 = Math.min(j3, j4);
|
|
|
|
} else if (j4 == Long.MIN_VALUE) {
|
2021-12-17 22:03:14 +00:00
|
|
|
i++;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-17 22:03:14 +00:00
|
|
|
if (length != i) {
|
|
|
|
int i2 = 0;
|
2021-06-27 20:44:35 +00:00
|
|
|
while (true) {
|
2021-12-17 22:03:14 +00:00
|
|
|
j2 = (long) i2;
|
2021-06-27 20:44:35 +00:00
|
|
|
if (j2 >= j3) {
|
|
|
|
break;
|
|
|
|
}
|
2021-12-17 22:03:14 +00:00
|
|
|
Object obj2 = this.n;
|
|
|
|
Object poll = this.l.poll();
|
2021-06-27 20:44:35 +00:00
|
|
|
boolean z3 = poll == null;
|
|
|
|
if (!a(obj2, z3)) {
|
|
|
|
if (z3) {
|
|
|
|
isEmpty = z3;
|
|
|
|
break;
|
|
|
|
}
|
2021-12-21 23:37:30 +00:00
|
|
|
Object b2 = e.b(poll);
|
2021-06-27 20:44:35 +00:00
|
|
|
for (a aVar2 : aVarArr) {
|
|
|
|
if (aVar2.get() > 0) {
|
|
|
|
try {
|
2021-12-21 23:37:30 +00:00
|
|
|
aVar2.child.onNext(b2);
|
2021-06-27 20:44:35 +00:00
|
|
|
aVar2.a(1);
|
|
|
|
} catch (Throwable th2) {
|
|
|
|
aVar2.unsubscribe();
|
2022-01-27 00:50:41 +00:00
|
|
|
f.p1(th2, aVar2.child, b2);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-12-17 22:03:14 +00:00
|
|
|
i2++;
|
2021-06-27 20:44:35 +00:00
|
|
|
isEmpty = z3;
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2021-12-17 22:03:14 +00:00
|
|
|
if (i2 > 0) {
|
2021-06-27 20:44:35 +00:00
|
|
|
request(j2);
|
|
|
|
}
|
|
|
|
if (j3 != 0) {
|
|
|
|
}
|
2021-12-17 22:03:14 +00:00
|
|
|
} else if (!a(this.n, this.l.poll() == null)) {
|
2021-06-27 20:44:35 +00:00
|
|
|
request(1);
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
synchronized (this) {
|
|
|
|
try {
|
2021-12-17 22:03:14 +00:00
|
|
|
if (!this.r) {
|
|
|
|
this.q = false;
|
2021-06-27 20:44:35 +00:00
|
|
|
try {
|
|
|
|
return;
|
|
|
|
} catch (Throwable th3) {
|
|
|
|
th = th3;
|
|
|
|
z2 = true;
|
|
|
|
while (true) {
|
|
|
|
try {
|
|
|
|
break;
|
|
|
|
} catch (Throwable th4) {
|
|
|
|
th = th4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw th;
|
|
|
|
}
|
|
|
|
} else {
|
2021-12-17 22:03:14 +00:00
|
|
|
this.r = false;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
} catch (Throwable th5) {
|
|
|
|
th = th5;
|
|
|
|
z2 = false;
|
|
|
|
while (true) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
throw th;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} catch (Throwable th6) {
|
|
|
|
Throwable th7 = th6;
|
|
|
|
z2 = false;
|
|
|
|
if (!z2) {
|
|
|
|
synchronized (this) {
|
2021-12-17 22:03:14 +00:00
|
|
|
this.q = false;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
throw th7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-08 18:25:28 +00:00
|
|
|
@Override // j0.g
|
2021-06-27 20:44:35 +00:00
|
|
|
public void onCompleted() {
|
2021-12-17 22:03:14 +00:00
|
|
|
if (this.n == null) {
|
|
|
|
this.n = e.a;
|
2021-06-27 20:44:35 +00:00
|
|
|
b();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-08 18:25:28 +00:00
|
|
|
@Override // j0.g
|
2021-06-27 20:44:35 +00:00
|
|
|
public void onError(Throwable th) {
|
2021-12-17 22:03:14 +00:00
|
|
|
if (this.n == null) {
|
|
|
|
this.n = new e.c(th);
|
2021-06-27 20:44:35 +00:00
|
|
|
b();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-08 18:25:28 +00:00
|
|
|
@Override // j0.g
|
2021-06-27 20:44:35 +00:00
|
|
|
public void onNext(T t) {
|
2021-12-17 22:03:14 +00:00
|
|
|
Queue<Object> queue = this.l;
|
2021-06-27 20:44:35 +00:00
|
|
|
if (t == null) {
|
2022-01-27 00:50:41 +00:00
|
|
|
t = (T) e.f3734b;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
if (!queue.offer(t)) {
|
|
|
|
MissingBackpressureException missingBackpressureException = new MissingBackpressureException();
|
2021-12-17 22:03:14 +00:00
|
|
|
if (this.n == null) {
|
|
|
|
this.n = new e.c(missingBackpressureException);
|
2021-06-27 20:44:35 +00:00
|
|
|
b();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
b();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // rx.Subscriber
|
|
|
|
public void onStart() {
|
2021-12-17 22:03:14 +00:00
|
|
|
request((long) i.j);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public h1(Observable.a<T> aVar, Observable<? extends T> observable, AtomicReference<b<T>> atomicReference) {
|
|
|
|
super(aVar);
|
2021-12-17 22:03:14 +00:00
|
|
|
this.k = observable;
|
|
|
|
this.l = atomicReference;
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
2021-11-08 18:25:28 +00:00
|
|
|
@Override // j0.m.b
|
2021-10-26 23:51:06 +00:00
|
|
|
public void k0(Action1<? super Subscription> action1) {
|
2021-06-27 20:44:35 +00:00
|
|
|
b<T> bVar;
|
|
|
|
while (true) {
|
2021-12-17 22:03:14 +00:00
|
|
|
bVar = this.l.get();
|
2021-06-27 20:44:35 +00:00
|
|
|
if (bVar != null && !bVar.isUnsubscribed()) {
|
|
|
|
break;
|
|
|
|
}
|
2021-12-17 22:03:14 +00:00
|
|
|
b<T> bVar2 = new b<>(this.l);
|
2021-11-08 18:25:28 +00:00
|
|
|
bVar2.add(new j0.r.a(new i1(bVar2)));
|
2021-12-17 22:03:14 +00:00
|
|
|
if (this.l.compareAndSet(bVar, bVar2)) {
|
2021-06-27 20:44:35 +00:00
|
|
|
bVar = bVar2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
boolean z2 = true;
|
2021-12-17 22:03:14 +00:00
|
|
|
if (bVar.p.get() || !bVar.p.compareAndSet(false, true)) {
|
2021-06-27 20:44:35 +00:00
|
|
|
z2 = false;
|
|
|
|
}
|
|
|
|
((z) action1).call(bVar);
|
|
|
|
if (z2) {
|
2021-12-17 22:03:14 +00:00
|
|
|
this.k.i0(bVar);
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|