88 lines
2.4 KiB
Java
88 lines
2.4 KiB
Java
package j0.l.a;
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import rx.Observable;
|
|
import rx.Scheduler;
|
|
import rx.Subscriber;
|
|
import rx.functions.Action0;
|
|
import rx.observers.SerializedSubscriber;
|
|
/* compiled from: OperatorSampleWithTime */
|
|
public final class n1<T> implements Observable.b<T, T> {
|
|
public final long i;
|
|
public final TimeUnit j;
|
|
public final Scheduler k;
|
|
|
|
/* compiled from: OperatorSampleWithTime */
|
|
public static final class a<T> extends Subscriber<T> implements Action0 {
|
|
public static final Object i = new Object();
|
|
public final Subscriber<? super T> j;
|
|
public final AtomicReference<Object> k = new AtomicReference<>(i);
|
|
|
|
public a(Subscriber<? super T> subscriber) {
|
|
this.j = subscriber;
|
|
}
|
|
|
|
public final void a() {
|
|
AtomicReference<Object> atomicReference = this.k;
|
|
Object obj = i;
|
|
Object andSet = atomicReference.getAndSet(obj);
|
|
if (andSet != obj) {
|
|
try {
|
|
this.j.onNext(andSet);
|
|
} catch (Throwable th) {
|
|
c.q.a.k.a.a0(th);
|
|
onError(th);
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // rx.functions.Action0
|
|
public void call() {
|
|
a();
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onCompleted() {
|
|
a();
|
|
this.j.onCompleted();
|
|
unsubscribe();
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onError(Throwable th) {
|
|
this.j.onError(th);
|
|
unsubscribe();
|
|
}
|
|
|
|
@Override // j0.g
|
|
public void onNext(T t) {
|
|
this.k.set(t);
|
|
}
|
|
|
|
@Override // rx.Subscriber
|
|
public void onStart() {
|
|
request(Long.MAX_VALUE);
|
|
}
|
|
}
|
|
|
|
public n1(long j, TimeUnit timeUnit, Scheduler scheduler) {
|
|
this.i = j;
|
|
this.j = timeUnit;
|
|
this.k = scheduler;
|
|
}
|
|
|
|
@Override // j0.k.b
|
|
public Object call(Object obj) {
|
|
Subscriber subscriber = (Subscriber) obj;
|
|
SerializedSubscriber serializedSubscriber = new SerializedSubscriber(subscriber);
|
|
Scheduler.Worker a2 = this.k.a();
|
|
subscriber.add(a2);
|
|
a aVar = new a(serializedSubscriber);
|
|
subscriber.add(aVar);
|
|
long j = this.i;
|
|
a2.c(aVar, j, j, this.j);
|
|
return aVar;
|
|
}
|
|
}
|