2021-06-27 20:44:35 +00:00
|
|
|
package j0.l.a;
|
|
|
|
|
|
|
|
import java.util.concurrent.atomic.AtomicLong;
|
|
|
|
import rx.Observable;
|
|
|
|
import rx.Producer;
|
|
|
|
import rx.Subscriber;
|
|
|
|
/* compiled from: OnSubscribeFromArray */
|
|
|
|
public final class o<T> implements Observable.a<T> {
|
|
|
|
public final T[] i;
|
|
|
|
|
|
|
|
/* compiled from: OnSubscribeFromArray */
|
|
|
|
public static final class a<T> extends AtomicLong implements Producer {
|
|
|
|
private static final long serialVersionUID = 3534218984725836979L;
|
|
|
|
public final T[] array;
|
|
|
|
public final Subscriber<? super T> child;
|
|
|
|
public int index;
|
|
|
|
|
|
|
|
public a(Subscriber<? super T> subscriber, T[] tArr) {
|
|
|
|
this.child = subscriber;
|
|
|
|
this.array = tArr;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // rx.Producer
|
|
|
|
public void j(long j) {
|
|
|
|
int i = (j > 0 ? 1 : (j == 0 ? 0 : -1));
|
|
|
|
if (i < 0) {
|
2021-07-27 04:36:47 +00:00
|
|
|
throw new IllegalArgumentException(c.d.b.a.a.o("n >= 0 required but it was ", j));
|
2021-06-27 20:44:35 +00:00
|
|
|
} else if (j == Long.MAX_VALUE) {
|
2021-07-09 21:07:36 +00:00
|
|
|
if (c.q.a.k.a.p(this, j) == 0) {
|
2021-06-27 20:44:35 +00:00
|
|
|
Subscriber<? super T> subscriber = this.child;
|
|
|
|
T[] tArr = this.array;
|
|
|
|
for (T t : tArr) {
|
|
|
|
if (!subscriber.isUnsubscribed()) {
|
|
|
|
subscriber.onNext(t);
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!subscriber.isUnsubscribed()) {
|
|
|
|
subscriber.onCompleted();
|
|
|
|
}
|
|
|
|
}
|
2021-07-09 21:07:36 +00:00
|
|
|
} else if (i != 0 && c.q.a.k.a.p(this, j) == 0) {
|
2021-06-27 20:44:35 +00:00
|
|
|
Subscriber<? super T> subscriber2 = this.child;
|
|
|
|
T[] tArr2 = this.array;
|
|
|
|
int length = tArr2.length;
|
|
|
|
int i2 = this.index;
|
|
|
|
do {
|
|
|
|
long j2 = 0;
|
|
|
|
while (true) {
|
|
|
|
if (j == 0 || i2 == length) {
|
|
|
|
j = get() + j2;
|
|
|
|
if (j == 0) {
|
|
|
|
this.index = i2;
|
|
|
|
j = addAndGet(j2);
|
|
|
|
}
|
|
|
|
} else if (!subscriber2.isUnsubscribed()) {
|
|
|
|
subscriber2.onNext(tArr2[i2]);
|
|
|
|
i2++;
|
|
|
|
if (i2 != length) {
|
|
|
|
j--;
|
|
|
|
j2--;
|
|
|
|
} else if (!subscriber2.isUnsubscribed()) {
|
|
|
|
subscriber2.onCompleted();
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (j != 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public o(T[] tArr) {
|
|
|
|
this.i = tArr;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // rx.functions.Action1
|
|
|
|
public void call(Object obj) {
|
|
|
|
Subscriber subscriber = (Subscriber) obj;
|
|
|
|
subscriber.setProducer(new a(subscriber, this.i));
|
|
|
|
}
|
|
|
|
}
|