128 lines
5.2 KiB
Java
128 lines
5.2 KiB
Java
|
package j0.l.a;
|
||
|
|
||
|
import java.util.Iterator;
|
||
|
import java.util.Objects;
|
||
|
import java.util.concurrent.atomic.AtomicLong;
|
||
|
import rx.Observable;
|
||
|
import rx.Producer;
|
||
|
import rx.Subscriber;
|
||
|
/* compiled from: OnSubscribeFromIterable */
|
||
|
public final class q<T> implements Observable.a<T> {
|
||
|
public final Iterable<? extends T> i;
|
||
|
|
||
|
/* compiled from: OnSubscribeFromIterable */
|
||
|
public static final class a<T> extends AtomicLong implements Producer {
|
||
|
private static final long serialVersionUID = -8730475647105475802L;
|
||
|
private final Iterator<? extends T> it;
|
||
|
private final Subscriber<? super T> o;
|
||
|
|
||
|
public a(Subscriber<? super T> subscriber, Iterator<? extends T> it) {
|
||
|
this.o = subscriber;
|
||
|
this.it = it;
|
||
|
}
|
||
|
|
||
|
@Override // rx.Producer
|
||
|
public void j(long j) {
|
||
|
if (get() != Long.MAX_VALUE) {
|
||
|
if (j == Long.MAX_VALUE && compareAndSet(0, Long.MAX_VALUE)) {
|
||
|
Subscriber<? super T> subscriber = this.o;
|
||
|
Iterator<? extends T> it = this.it;
|
||
|
while (!subscriber.isUnsubscribed()) {
|
||
|
try {
|
||
|
subscriber.onNext((Object) it.next());
|
||
|
if (!subscriber.isUnsubscribed()) {
|
||
|
try {
|
||
|
if (!it.hasNext()) {
|
||
|
if (!subscriber.isUnsubscribed()) {
|
||
|
subscriber.onCompleted();
|
||
|
return;
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
} catch (Throwable th) {
|
||
|
c.q.a.k.a.Z(th);
|
||
|
subscriber.onError(th);
|
||
|
return;
|
||
|
}
|
||
|
} else {
|
||
|
return;
|
||
|
}
|
||
|
} catch (Throwable th2) {
|
||
|
c.q.a.k.a.Z(th2);
|
||
|
subscriber.onError(th2);
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
} else if (j > 0 && c.q.a.k.a.o(this, j) == 0) {
|
||
|
Subscriber<? super T> subscriber2 = this.o;
|
||
|
Iterator<? extends T> it2 = this.it;
|
||
|
do {
|
||
|
long j2 = 0;
|
||
|
while (true) {
|
||
|
if (j2 == j) {
|
||
|
j = get();
|
||
|
if (j2 == j) {
|
||
|
j = c.q.a.k.a.H(this, j2);
|
||
|
}
|
||
|
} else if (!subscriber2.isUnsubscribed()) {
|
||
|
try {
|
||
|
subscriber2.onNext((Object) it2.next());
|
||
|
if (!subscriber2.isUnsubscribed()) {
|
||
|
try {
|
||
|
if (it2.hasNext()) {
|
||
|
j2++;
|
||
|
} else if (!subscriber2.isUnsubscribed()) {
|
||
|
subscriber2.onCompleted();
|
||
|
return;
|
||
|
} else {
|
||
|
return;
|
||
|
}
|
||
|
} catch (Throwable th3) {
|
||
|
c.q.a.k.a.Z(th3);
|
||
|
subscriber2.onError(th3);
|
||
|
return;
|
||
|
}
|
||
|
} else {
|
||
|
return;
|
||
|
}
|
||
|
} catch (Throwable th4) {
|
||
|
c.q.a.k.a.Z(th4);
|
||
|
subscriber2.onError(th4);
|
||
|
return;
|
||
|
}
|
||
|
} else {
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
} while (j != 0);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public q(Iterable<? extends T> iterable) {
|
||
|
Objects.requireNonNull(iterable, "iterable must not be null");
|
||
|
this.i = iterable;
|
||
|
}
|
||
|
|
||
|
@Override // rx.functions.Action1
|
||
|
public void call(Object obj) {
|
||
|
Subscriber subscriber = (Subscriber) obj;
|
||
|
try {
|
||
|
Iterator<? extends T> it = this.i.iterator();
|
||
|
boolean hasNext = it.hasNext();
|
||
|
if (subscriber.isUnsubscribed()) {
|
||
|
return;
|
||
|
}
|
||
|
if (!hasNext) {
|
||
|
subscriber.onCompleted();
|
||
|
} else {
|
||
|
subscriber.setProducer(new a(subscriber, it));
|
||
|
}
|
||
|
} catch (Throwable th) {
|
||
|
c.q.a.k.a.Z(th);
|
||
|
subscriber.onError(th);
|
||
|
}
|
||
|
}
|
||
|
}
|