jimu-decompiled/sources/io/reactivex/internal/operators/flowable/FlowableOnBackpressureDrop.java
2025-05-13 19:24:51 +02:00

103 lines
3.1 KiB
Java

package io.reactivex.internal.operators.flowable;
import io.reactivex.Flowable;
import io.reactivex.FlowableSubscriber;
import io.reactivex.exceptions.Exceptions;
import io.reactivex.functions.Consumer;
import io.reactivex.internal.subscriptions.SubscriptionHelper;
import io.reactivex.internal.util.BackpressureHelper;
import io.reactivex.plugins.RxJavaPlugins;
import java.util.concurrent.atomic.AtomicLong;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
/* loaded from: classes2.dex */
public final class FlowableOnBackpressureDrop<T> extends AbstractFlowableWithUpstream<T, T> implements Consumer<T> {
final Consumer<? super T> c;
static final class BackpressureDropSubscriber<T> extends AtomicLong implements FlowableSubscriber<T>, Subscription {
final Subscriber<? super T> a;
final Consumer<? super T> b;
Subscription c;
boolean d;
BackpressureDropSubscriber(Subscriber<? super T> subscriber, Consumer<? super T> consumer) {
this.a = subscriber;
this.b = consumer;
}
@Override // org.reactivestreams.Subscription
public void cancel() {
this.c.cancel();
}
@Override // org.reactivestreams.Subscriber
public void onComplete() {
if (this.d) {
return;
}
this.d = true;
this.a.onComplete();
}
@Override // org.reactivestreams.Subscriber
public void onError(Throwable th) {
if (this.d) {
RxJavaPlugins.b(th);
} else {
this.d = true;
this.a.onError(th);
}
}
@Override // org.reactivestreams.Subscriber
public void onNext(T t) {
if (this.d) {
return;
}
if (get() != 0) {
this.a.onNext(t);
BackpressureHelper.b(this, 1L);
return;
}
try {
this.b.accept(t);
} catch (Throwable th) {
Exceptions.b(th);
cancel();
onError(th);
}
}
@Override // org.reactivestreams.Subscriber
public void onSubscribe(Subscription subscription) {
if (SubscriptionHelper.validate(this.c, subscription)) {
this.c = subscription;
this.a.onSubscribe(this);
subscription.request(Long.MAX_VALUE);
}
}
@Override // org.reactivestreams.Subscription
public void request(long j) {
if (SubscriptionHelper.validate(j)) {
BackpressureHelper.a(this, j);
}
}
}
public FlowableOnBackpressureDrop(Flowable<T> flowable) {
super(flowable);
this.c = this;
}
@Override // io.reactivex.functions.Consumer
public void accept(T t) {
}
@Override // io.reactivex.Flowable
protected void b(Subscriber<? super T> subscriber) {
this.b.a((FlowableSubscriber) new BackpressureDropSubscriber(subscriber, this.c));
}
}