mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-18 11:57:18 +01:00
104 lines
3.6 KiB
Java
104 lines
3.6 KiB
Java
package io.reactivex.rxjava3.internal.subscribers;
|
|
|
|
import io.reactivex.rxjava3.core.FlowableSubscriber;
|
|
import io.reactivex.rxjava3.internal.subscriptions.SubscriptionHelper;
|
|
import io.reactivex.rxjava3.internal.util.QueueDrainHelper;
|
|
import io.reactivex.rxjava3.operators.QueueSubscription;
|
|
import io.reactivex.rxjava3.operators.SimpleQueue;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import org.reactivestreams.Subscription;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes10.dex */
|
|
public final class InnerQueuedSubscriber<T> extends AtomicReference<Subscription> implements FlowableSubscriber<T>, Subscription {
|
|
private static final long serialVersionUID = 22876611072430776L;
|
|
volatile boolean done;
|
|
int fusionMode;
|
|
final int limit;
|
|
final InnerQueuedSubscriberSupport<T> parent;
|
|
final int prefetch;
|
|
long produced;
|
|
volatile SimpleQueue<T> queue;
|
|
|
|
public InnerQueuedSubscriber(InnerQueuedSubscriberSupport<T> innerQueuedSubscriberSupport, int i) {
|
|
this.parent = innerQueuedSubscriberSupport;
|
|
this.prefetch = i;
|
|
this.limit = i - (i >> 2);
|
|
}
|
|
|
|
@Override // org.reactivestreams.Subscription
|
|
public void cancel() {
|
|
SubscriptionHelper.cancel(this);
|
|
}
|
|
|
|
public boolean isDone() {
|
|
return this.done;
|
|
}
|
|
|
|
@Override // org.reactivestreams.Subscriber
|
|
public void onComplete() {
|
|
this.parent.innerComplete(this);
|
|
}
|
|
|
|
@Override // org.reactivestreams.Subscriber
|
|
public void onError(Throwable th) {
|
|
this.parent.innerError(this, th);
|
|
}
|
|
|
|
@Override // org.reactivestreams.Subscriber
|
|
public void onNext(T t) {
|
|
int i = this.fusionMode;
|
|
InnerQueuedSubscriberSupport<T> innerQueuedSubscriberSupport = this.parent;
|
|
if (i == 0) {
|
|
innerQueuedSubscriberSupport.innerNext(this, t);
|
|
} else {
|
|
innerQueuedSubscriberSupport.drain();
|
|
}
|
|
}
|
|
|
|
@Override // io.reactivex.rxjava3.core.FlowableSubscriber, org.reactivestreams.Subscriber
|
|
public void onSubscribe(Subscription subscription) {
|
|
if (SubscriptionHelper.setOnce(this, subscription)) {
|
|
if (subscription instanceof QueueSubscription) {
|
|
QueueSubscription queueSubscription = (QueueSubscription) subscription;
|
|
int requestFusion = queueSubscription.requestFusion(3);
|
|
if (requestFusion == 1) {
|
|
this.fusionMode = requestFusion;
|
|
this.queue = queueSubscription;
|
|
this.done = true;
|
|
this.parent.innerComplete(this);
|
|
return;
|
|
}
|
|
if (requestFusion == 2) {
|
|
this.fusionMode = requestFusion;
|
|
this.queue = queueSubscription;
|
|
QueueDrainHelper.request(subscription, this.prefetch);
|
|
return;
|
|
}
|
|
}
|
|
this.queue = QueueDrainHelper.createQueue(this.prefetch);
|
|
QueueDrainHelper.request(subscription, this.prefetch);
|
|
}
|
|
}
|
|
|
|
public SimpleQueue<T> queue() {
|
|
return this.queue;
|
|
}
|
|
|
|
@Override // org.reactivestreams.Subscription
|
|
public void request(long j) {
|
|
if (this.fusionMode != 1) {
|
|
long j2 = this.produced + j;
|
|
if (j2 < this.limit) {
|
|
this.produced = j2;
|
|
} else {
|
|
this.produced = 0L;
|
|
get().request(j2);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setDone() {
|
|
this.done = true;
|
|
}
|
|
}
|