272 lines
11 KiB
Java
272 lines
11 KiB
Java
|
package j0.l.a;
|
||
|
|
||
|
import j0.l.a.q;
|
||
|
import j0.l.e.d;
|
||
|
import j0.l.e.h;
|
||
|
import j0.l.e.m.c;
|
||
|
import j0.l.e.m.e;
|
||
|
import j0.l.e.n.y;
|
||
|
import j0.o.l;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.Queue;
|
||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||
|
import java.util.concurrent.atomic.AtomicLong;
|
||
|
import java.util.concurrent.atomic.AtomicReference;
|
||
|
import rx.Observable;
|
||
|
import rx.Subscriber;
|
||
|
import rx.exceptions.MissingBackpressureException;
|
||
|
/* compiled from: OnSubscribeFlattenIterable */
|
||
|
public final class n<T, R> implements Observable.a<R> {
|
||
|
public final Observable<? extends T> i;
|
||
|
public final j0.k.b<? super T, ? extends Iterable<? extends R>> j;
|
||
|
public final int k;
|
||
|
|
||
|
/* compiled from: OnSubscribeFlattenIterable */
|
||
|
public static final class a<T, R> extends Subscriber<T> {
|
||
|
public final Subscriber<? super R> i;
|
||
|
public final j0.k.b<? super T, ? extends Iterable<? extends R>> j;
|
||
|
public final long k;
|
||
|
public final Queue<Object> l;
|
||
|
public final AtomicReference<Throwable> m = new AtomicReference<>();
|
||
|
public final AtomicLong n = new AtomicLong();
|
||
|
public final AtomicInteger o = new AtomicInteger();
|
||
|
public volatile boolean p;
|
||
|
public long q;
|
||
|
public Iterator<? extends R> r;
|
||
|
|
||
|
public a(Subscriber<? super R> subscriber, j0.k.b<? super T, ? extends Iterable<? extends R>> bVar, int i) {
|
||
|
this.i = subscriber;
|
||
|
this.j = bVar;
|
||
|
if (i == Integer.MAX_VALUE) {
|
||
|
this.k = Long.MAX_VALUE;
|
||
|
this.l = new e(h.i);
|
||
|
} else {
|
||
|
this.k = (long) (i - (i >> 2));
|
||
|
if (y.b()) {
|
||
|
this.l = new j0.l.e.n.n(i);
|
||
|
} else {
|
||
|
this.l = new c(i);
|
||
|
}
|
||
|
}
|
||
|
request((long) i);
|
||
|
}
|
||
|
|
||
|
public boolean a(boolean z2, boolean z3, Subscriber<?> subscriber, Queue<?> queue) {
|
||
|
if (subscriber.isUnsubscribed()) {
|
||
|
queue.clear();
|
||
|
this.r = null;
|
||
|
return true;
|
||
|
} else if (!z2) {
|
||
|
return false;
|
||
|
} else {
|
||
|
if (this.m.get() != null) {
|
||
|
Throwable h = d.h(this.m);
|
||
|
unsubscribe();
|
||
|
queue.clear();
|
||
|
this.r = null;
|
||
|
subscriber.onError(h);
|
||
|
return true;
|
||
|
} else if (!z3) {
|
||
|
return false;
|
||
|
} else {
|
||
|
subscriber.onCompleted();
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX WARNING: Removed duplicated region for block: B:26:0x0066 */
|
||
|
/* JADX WARNING: Removed duplicated region for block: B:49:0x00af */
|
||
|
/* JADX WARNING: Removed duplicated region for block: B:58:0x00c5 */
|
||
|
/* JADX WARNING: Removed duplicated region for block: B:67:0x00cf A[SYNTHETIC] */
|
||
|
/* JADX WARNING: Removed duplicated region for block: B:68:0x00cf A[SYNTHETIC] */
|
||
|
/* JADX WARNING: Removed duplicated region for block: B:70:0x00cc A[SYNTHETIC] */
|
||
|
/* JADX WARNING: Removed duplicated region for block: B:72:0x00d8 A[SYNTHETIC] */
|
||
|
/* JADX WARNING: Removed duplicated region for block: B:75:0x0010 A[SYNTHETIC] */
|
||
|
public void b() {
|
||
|
Iterator<? extends R> it;
|
||
|
int i;
|
||
|
long j;
|
||
|
long j2;
|
||
|
if (this.o.getAndIncrement() == 0) {
|
||
|
Subscriber<? super R> subscriber = this.i;
|
||
|
Queue<?> queue = this.l;
|
||
|
int i2 = 1;
|
||
|
while (true) {
|
||
|
it = this.r;
|
||
|
boolean z2 = false;
|
||
|
if (it == null) {
|
||
|
boolean z3 = this.p;
|
||
|
Object poll = queue.poll();
|
||
|
boolean z4 = poll == null;
|
||
|
if (!a(z3, z4, subscriber, queue)) {
|
||
|
if (!z4) {
|
||
|
long j3 = this.q + 1;
|
||
|
i = i2;
|
||
|
if (j3 == this.k) {
|
||
|
this.q = 0;
|
||
|
request(j3);
|
||
|
} else {
|
||
|
this.q = j3;
|
||
|
}
|
||
|
try {
|
||
|
it = ((Iterable) this.j.call((Object) e.b(poll))).iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
i2 = i;
|
||
|
} else {
|
||
|
this.r = it;
|
||
|
if (it == null) {
|
||
|
j = this.n.get();
|
||
|
j2 = 0;
|
||
|
while (true) {
|
||
|
if (j2 == j) {
|
||
|
break;
|
||
|
} else if (!a(this.p, false, subscriber, queue)) {
|
||
|
try {
|
||
|
subscriber.onNext((Object) it.next());
|
||
|
if (!a(this.p, false, subscriber, queue)) {
|
||
|
j2++;
|
||
|
try {
|
||
|
if (!it.hasNext()) {
|
||
|
this.r = null;
|
||
|
break;
|
||
|
}
|
||
|
} catch (Throwable th) {
|
||
|
c.q.a.k.a.Z(th);
|
||
|
this.r = null;
|
||
|
onError(th);
|
||
|
}
|
||
|
} else {
|
||
|
return;
|
||
|
}
|
||
|
} catch (Throwable th2) {
|
||
|
c.q.a.k.a.Z(th2);
|
||
|
this.r = null;
|
||
|
onError(th2);
|
||
|
}
|
||
|
} else {
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
if (j2 == j) {
|
||
|
boolean z5 = this.p;
|
||
|
if (queue.isEmpty() && it == null) {
|
||
|
z2 = true;
|
||
|
}
|
||
|
if (a(z5, z2, subscriber, queue)) {
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
if (j2 != 0) {
|
||
|
c.q.a.k.a.H(this.n, j2);
|
||
|
}
|
||
|
if (it != null) {
|
||
|
i2 = i;
|
||
|
}
|
||
|
}
|
||
|
i2 = this.o.addAndGet(-i);
|
||
|
if (i2 != 0) {
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
} catch (Throwable th3) {
|
||
|
c.q.a.k.a.Z(th3);
|
||
|
onError(th3);
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
i = i2;
|
||
|
if (it == null) {
|
||
|
}
|
||
|
i2 = this.o.addAndGet(-i);
|
||
|
if (i2 != 0) {
|
||
|
}
|
||
|
}
|
||
|
} else {
|
||
|
return;
|
||
|
}
|
||
|
it = null;
|
||
|
if (j2 == j) {
|
||
|
}
|
||
|
if (j2 != 0) {
|
||
|
}
|
||
|
if (it != null) {
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // j0.g
|
||
|
public void onCompleted() {
|
||
|
this.p = true;
|
||
|
b();
|
||
|
}
|
||
|
|
||
|
@Override // j0.g
|
||
|
public void onError(Throwable th) {
|
||
|
if (d.f(this.m, th)) {
|
||
|
this.p = true;
|
||
|
b();
|
||
|
return;
|
||
|
}
|
||
|
l.b(th);
|
||
|
}
|
||
|
|
||
|
@Override // j0.g
|
||
|
public void onNext(T t) {
|
||
|
Queue<Object> queue = this.l;
|
||
|
if (t == null) {
|
||
|
t = (T) e.b;
|
||
|
}
|
||
|
if (!queue.offer(t)) {
|
||
|
unsubscribe();
|
||
|
onError(new MissingBackpressureException());
|
||
|
return;
|
||
|
}
|
||
|
b();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* compiled from: OnSubscribeFlattenIterable */
|
||
|
public static final class b<T, R> implements Observable.a<R> {
|
||
|
public final T i;
|
||
|
public final j0.k.b<? super T, ? extends Iterable<? extends R>> j;
|
||
|
|
||
|
public b(T t, j0.k.b<? super T, ? extends Iterable<? extends R>> bVar) {
|
||
|
this.i = t;
|
||
|
this.j = bVar;
|
||
|
}
|
||
|
|
||
|
@Override // rx.functions.Action1
|
||
|
public void call(Object obj) {
|
||
|
Subscriber subscriber = (Subscriber) obj;
|
||
|
try {
|
||
|
Iterator<T> it = ((Iterable) this.j.call(this.i)).iterator();
|
||
|
if (!it.hasNext()) {
|
||
|
subscriber.onCompleted();
|
||
|
} else {
|
||
|
subscriber.setProducer(new q.a(subscriber, it));
|
||
|
}
|
||
|
} catch (Throwable th) {
|
||
|
c.q.a.k.a.a0(th, subscriber, this.i);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public n(Observable<? extends T> observable, j0.k.b<? super T, ? extends Iterable<? extends R>> bVar, int i) {
|
||
|
this.i = observable;
|
||
|
this.j = bVar;
|
||
|
this.k = i;
|
||
|
}
|
||
|
|
||
|
@Override // rx.functions.Action1
|
||
|
public void call(Object obj) {
|
||
|
Subscriber subscriber = (Subscriber) obj;
|
||
|
a aVar = new a(subscriber, this.j, this.k);
|
||
|
subscriber.add(aVar);
|
||
|
subscriber.setProducer(new m(this, aVar));
|
||
|
this.i.j0(aVar);
|
||
|
}
|
||
|
}
|