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 extends AbstractFlowableWithUpstream implements Consumer { final Consumer c; static final class BackpressureDropSubscriber extends AtomicLong implements FlowableSubscriber, Subscription { final Subscriber a; final Consumer b; Subscription c; boolean d; BackpressureDropSubscriber(Subscriber subscriber, Consumer 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 flowable) { super(flowable); this.c = this; } @Override // io.reactivex.functions.Consumer public void accept(T t) { } @Override // io.reactivex.Flowable protected void b(Subscriber subscriber) { this.b.a((FlowableSubscriber) new BackpressureDropSubscriber(subscriber, this.c)); } }