168 lines
5.1 KiB
Java
168 lines
5.1 KiB
Java
package j0.l.a;
|
|
|
|
import j0.o.l;
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeoutException;
|
|
import java.util.concurrent.atomic.AtomicLong;
|
|
import rx.Observable;
|
|
import rx.Producer;
|
|
import rx.Scheduler;
|
|
import rx.Subscriber;
|
|
import rx.Subscription;
|
|
import rx.functions.Action0;
|
|
/* compiled from: OnSubscribeTimeoutTimedWithFallback */
|
|
public final class g0<T> implements Observable.a<T> {
|
|
public final Observable<T> i;
|
|
public final long j;
|
|
public final TimeUnit k;
|
|
public final Scheduler l;
|
|
public final Observable<? extends T> m;
|
|
|
|
/* compiled from: OnSubscribeTimeoutTimedWithFallback */
|
|
public static final class a<T> extends Subscriber<T> {
|
|
public final Subscriber<? super T> i;
|
|
public final j0.l.b.a j;
|
|
|
|
public a(Subscriber<? super T> subscriber, j0.l.b.a aVar) {
|
|
this.i = subscriber;
|
|
this.j = aVar;
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onCompleted() {
|
|
this.i.onCompleted();
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onError(Throwable th) {
|
|
this.i.onError(th);
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onNext(T t) {
|
|
this.i.onNext(t);
|
|
}
|
|
|
|
@Override // rx.Subscriber
|
|
public void setProducer(Producer producer) {
|
|
this.j.c(producer);
|
|
}
|
|
}
|
|
|
|
/* compiled from: OnSubscribeTimeoutTimedWithFallback */
|
|
public static final class b<T> extends Subscriber<T> {
|
|
public final Subscriber<? super T> i;
|
|
public final long j;
|
|
public final TimeUnit k;
|
|
public final Scheduler.Worker l;
|
|
public final Observable<? extends T> m;
|
|
public final j0.l.b.a n = new j0.l.b.a();
|
|
public final AtomicLong o = new AtomicLong();
|
|
public final j0.l.d.a p;
|
|
public final j0.l.d.a q;
|
|
public long r;
|
|
|
|
/* compiled from: OnSubscribeTimeoutTimedWithFallback */
|
|
public final class a implements Action0 {
|
|
public final long i;
|
|
|
|
public a(long j) {
|
|
this.i = j;
|
|
}
|
|
|
|
@Override // rx.functions.Action0
|
|
public void call() {
|
|
b bVar = b.this;
|
|
if (bVar.o.compareAndSet(this.i, Long.MAX_VALUE)) {
|
|
bVar.unsubscribe();
|
|
if (bVar.m == null) {
|
|
bVar.i.onError(new TimeoutException());
|
|
return;
|
|
}
|
|
long j = bVar.r;
|
|
if (j != 0) {
|
|
bVar.n.b(j);
|
|
}
|
|
a aVar = new a(bVar.i, bVar.n);
|
|
if (bVar.q.a(aVar)) {
|
|
bVar.m.U(aVar);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public b(Subscriber<? super T> subscriber, long j, TimeUnit timeUnit, Scheduler.Worker worker, Observable<? extends T> observable) {
|
|
this.i = subscriber;
|
|
this.j = j;
|
|
this.k = timeUnit;
|
|
this.l = worker;
|
|
this.m = observable;
|
|
j0.l.d.a aVar = new j0.l.d.a();
|
|
this.p = aVar;
|
|
this.q = new j0.l.d.a(this);
|
|
add(worker);
|
|
add(aVar);
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onCompleted() {
|
|
if (this.o.getAndSet(Long.MAX_VALUE) != Long.MAX_VALUE) {
|
|
this.p.unsubscribe();
|
|
this.i.onCompleted();
|
|
this.l.unsubscribe();
|
|
}
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onError(Throwable th) {
|
|
if (this.o.getAndSet(Long.MAX_VALUE) != Long.MAX_VALUE) {
|
|
this.p.unsubscribe();
|
|
this.i.onError(th);
|
|
this.l.unsubscribe();
|
|
return;
|
|
}
|
|
l.b(th);
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onNext(T t) {
|
|
long j = this.o.get();
|
|
if (j != Long.MAX_VALUE) {
|
|
long j2 = j + 1;
|
|
if (this.o.compareAndSet(j, j2)) {
|
|
Subscription subscription = this.p.get();
|
|
if (subscription != null) {
|
|
subscription.unsubscribe();
|
|
}
|
|
this.r++;
|
|
this.i.onNext(t);
|
|
this.p.a(this.l.b(new a(j2), this.j, this.k));
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // rx.Subscriber
|
|
public void setProducer(Producer producer) {
|
|
this.n.c(producer);
|
|
}
|
|
}
|
|
|
|
public g0(Observable<T> observable, long j, TimeUnit timeUnit, Scheduler scheduler, Observable<? extends T> observable2) {
|
|
this.i = observable;
|
|
this.j = j;
|
|
this.k = timeUnit;
|
|
this.l = scheduler;
|
|
this.m = observable2;
|
|
}
|
|
|
|
@Override // rx.functions.Action1
|
|
public void call(Object obj) {
|
|
Subscriber subscriber = (Subscriber) obj;
|
|
b bVar = new b(subscriber, this.j, this.k, this.l.a(), this.m);
|
|
subscriber.add(bVar.q);
|
|
subscriber.setProducer(bVar.n);
|
|
bVar.p.a(bVar.l.b(new b.a(0), bVar.j, bVar.k));
|
|
this.i.U(bVar);
|
|
}
|
|
}
|