2021-06-27 20:44:35 +00:00
|
|
|
package j0.l.a;
|
|
|
|
|
|
|
|
import j0.o.l;
|
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
import java.util.concurrent.atomic.AtomicReferenceArray;
|
|
|
|
import rx.Observable;
|
|
|
|
import rx.Producer;
|
|
|
|
import rx.Subscriber;
|
|
|
|
import rx.functions.FuncN;
|
|
|
|
import rx.observers.SerializedSubscriber;
|
|
|
|
/* compiled from: OperatorWithLatestFromMany */
|
|
|
|
public final class q2<T, R> implements Observable.a<R> {
|
|
|
|
public final Observable<T> i;
|
|
|
|
public final Observable<?>[] j;
|
|
|
|
public final FuncN<R> k;
|
|
|
|
|
|
|
|
/* compiled from: OperatorWithLatestFromMany */
|
|
|
|
public static final class a<T, R> extends Subscriber<T> {
|
|
|
|
public static final Object i = new Object();
|
|
|
|
public final Subscriber<? super R> j;
|
|
|
|
public final FuncN<R> k;
|
|
|
|
public final AtomicReferenceArray<Object> l;
|
|
|
|
public final AtomicInteger m;
|
|
|
|
public boolean n;
|
|
|
|
|
|
|
|
public a(Subscriber<? super R> subscriber, FuncN<R> funcN, int i2) {
|
|
|
|
this.j = subscriber;
|
|
|
|
this.k = funcN;
|
|
|
|
AtomicReferenceArray<Object> atomicReferenceArray = new AtomicReferenceArray<>(i2 + 1);
|
|
|
|
for (int i3 = 0; i3 <= i2; i3++) {
|
|
|
|
atomicReferenceArray.lazySet(i3, i);
|
|
|
|
}
|
|
|
|
this.l = atomicReferenceArray;
|
|
|
|
this.m = new AtomicInteger(i2);
|
|
|
|
request(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // j0.g
|
|
|
|
public void onCompleted() {
|
|
|
|
if (!this.n) {
|
|
|
|
this.n = true;
|
|
|
|
unsubscribe();
|
|
|
|
this.j.onCompleted();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // j0.g
|
|
|
|
public void onError(Throwable th) {
|
|
|
|
if (this.n) {
|
|
|
|
l.b(th);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
this.n = true;
|
|
|
|
unsubscribe();
|
|
|
|
this.j.onError(th);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // j0.g
|
|
|
|
public void onNext(T t) {
|
|
|
|
if (!this.n) {
|
|
|
|
if (this.m.get() == 0) {
|
|
|
|
AtomicReferenceArray<Object> atomicReferenceArray = this.l;
|
|
|
|
int length = atomicReferenceArray.length();
|
|
|
|
atomicReferenceArray.lazySet(0, t);
|
|
|
|
Object[] objArr = new Object[atomicReferenceArray.length()];
|
|
|
|
for (int i2 = 0; i2 < length; i2++) {
|
|
|
|
objArr[i2] = atomicReferenceArray.get(i2);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
this.j.onNext(this.k.call(objArr));
|
|
|
|
} catch (Throwable th) {
|
2021-06-27 20:53:42 +00:00
|
|
|
c.q.a.k.a.a0(th);
|
2021-06-27 20:44:35 +00:00
|
|
|
onError(th);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
request(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // rx.Subscriber
|
|
|
|
public void setProducer(Producer producer) {
|
|
|
|
super.setProducer(producer);
|
|
|
|
this.j.setProducer(producer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compiled from: OperatorWithLatestFromMany */
|
|
|
|
public static final class b extends Subscriber<Object> {
|
|
|
|
public final a<?, ?> i;
|
|
|
|
public final int j;
|
|
|
|
|
|
|
|
public b(a<?, ?> aVar, int i) {
|
|
|
|
this.i = aVar;
|
|
|
|
this.j = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // j0.g
|
|
|
|
public void onCompleted() {
|
|
|
|
a<?, ?> aVar = this.i;
|
|
|
|
if (aVar.l.get(this.j) == a.i) {
|
|
|
|
aVar.onCompleted();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // j0.g
|
|
|
|
public void onError(Throwable th) {
|
|
|
|
this.i.onError(th);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // j0.g
|
|
|
|
public void onNext(Object obj) {
|
|
|
|
a<?, ?> aVar = this.i;
|
|
|
|
if (aVar.l.getAndSet(this.j, obj) == a.i) {
|
|
|
|
aVar.m.decrementAndGet();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public q2(Observable<T> observable, Observable<?>[] observableArr, Iterable<Observable<?>> iterable, FuncN<R> funcN) {
|
|
|
|
this.i = observable;
|
|
|
|
this.j = observableArr;
|
|
|
|
this.k = funcN;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // rx.functions.Action1
|
|
|
|
public void call(Object obj) {
|
|
|
|
Subscriber subscriber = (Subscriber) obj;
|
|
|
|
SerializedSubscriber serializedSubscriber = new SerializedSubscriber(subscriber);
|
|
|
|
Observable<?>[] observableArr = this.j;
|
|
|
|
int i = 0;
|
|
|
|
Objects.requireNonNull(observableArr);
|
|
|
|
int length = observableArr.length;
|
|
|
|
a aVar = new a(subscriber, this.k, length);
|
|
|
|
serializedSubscriber.add(aVar);
|
|
|
|
while (i < length) {
|
|
|
|
if (!serializedSubscriber.isUnsubscribed()) {
|
|
|
|
int i2 = i + 1;
|
|
|
|
b bVar = new b(aVar, i2);
|
|
|
|
aVar.add(bVar);
|
|
|
|
observableArr[i].j0(bVar);
|
|
|
|
i = i2;
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.i.j0(aVar);
|
|
|
|
}
|
|
|
|
}
|