58 lines
1.8 KiB
Java
58 lines
1.8 KiB
Java
package io.reactivex.internal.subscribers;
|
|
|
|
import io.reactivex.FlowableSubscriber;
|
|
import io.reactivex.internal.subscriptions.SubscriptionHelper;
|
|
import io.reactivex.internal.util.NotificationLite;
|
|
import java.util.Queue;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import org.reactivestreams.Subscription;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class BlockingSubscriber<T> extends AtomicReference<Subscription> implements FlowableSubscriber<T>, Subscription {
|
|
public static final Object TERMINATED = new Object();
|
|
private static final long serialVersionUID = -4875965440900746268L;
|
|
final Queue<Object> queue;
|
|
|
|
public BlockingSubscriber(Queue<Object> queue) {
|
|
this.queue = queue;
|
|
}
|
|
|
|
@Override // org.reactivestreams.Subscription
|
|
public void cancel() {
|
|
if (SubscriptionHelper.cancel(this)) {
|
|
this.queue.offer(TERMINATED);
|
|
}
|
|
}
|
|
|
|
public boolean isCancelled() {
|
|
return get() == SubscriptionHelper.CANCELLED;
|
|
}
|
|
|
|
@Override // org.reactivestreams.Subscriber
|
|
public void onComplete() {
|
|
this.queue.offer(NotificationLite.complete());
|
|
}
|
|
|
|
@Override // org.reactivestreams.Subscriber
|
|
public void onError(Throwable th) {
|
|
this.queue.offer(NotificationLite.error(th));
|
|
}
|
|
|
|
@Override // org.reactivestreams.Subscriber
|
|
public void onNext(T t) {
|
|
this.queue.offer(NotificationLite.next(t));
|
|
}
|
|
|
|
@Override // org.reactivestreams.Subscriber
|
|
public void onSubscribe(Subscription subscription) {
|
|
if (SubscriptionHelper.setOnce(this, subscription)) {
|
|
this.queue.offer(NotificationLite.subscription(this));
|
|
}
|
|
}
|
|
|
|
@Override // org.reactivestreams.Subscription
|
|
public void request(long j) {
|
|
get().request(j);
|
|
}
|
|
}
|