mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-17 03:17:17 +01:00
85 lines
2.9 KiB
Java
85 lines
2.9 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.BackpressureHelper;
|
|
import java.util.concurrent.atomic.AtomicLong;
|
|
import org.reactivestreams.Subscriber;
|
|
import org.reactivestreams.Subscription;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes10.dex */
|
|
public abstract class SinglePostCompleteSubscriber<T, R> extends AtomicLong implements FlowableSubscriber<T>, Subscription {
|
|
static final long COMPLETE_MASK = Long.MIN_VALUE;
|
|
static final long REQUEST_MASK = Long.MAX_VALUE;
|
|
private static final long serialVersionUID = 7917814472626990048L;
|
|
protected final Subscriber<? super R> downstream;
|
|
protected long produced;
|
|
protected Subscription upstream;
|
|
protected R value;
|
|
|
|
public SinglePostCompleteSubscriber(Subscriber<? super R> subscriber) {
|
|
this.downstream = subscriber;
|
|
}
|
|
|
|
public void cancel() {
|
|
this.upstream.cancel();
|
|
}
|
|
|
|
public final void complete(R r) {
|
|
long j = this.produced;
|
|
if (j != 0) {
|
|
BackpressureHelper.produced(this, j);
|
|
}
|
|
while (true) {
|
|
long j2 = get();
|
|
if ((j2 & Long.MIN_VALUE) != 0) {
|
|
onDrop(r);
|
|
return;
|
|
}
|
|
if ((j2 & Long.MAX_VALUE) != 0) {
|
|
lazySet(-9223372036854775807L);
|
|
this.downstream.onNext(r);
|
|
this.downstream.onComplete();
|
|
return;
|
|
} else {
|
|
this.value = r;
|
|
if (compareAndSet(0L, Long.MIN_VALUE)) {
|
|
return;
|
|
} else {
|
|
this.value = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // io.reactivex.rxjava3.core.FlowableSubscriber, org.reactivestreams.Subscriber
|
|
public void onSubscribe(Subscription subscription) {
|
|
if (SubscriptionHelper.validate(this.upstream, subscription)) {
|
|
this.upstream = subscription;
|
|
this.downstream.onSubscribe(this);
|
|
}
|
|
}
|
|
|
|
@Override // org.reactivestreams.Subscription
|
|
public final void request(long j) {
|
|
long j2;
|
|
if (SubscriptionHelper.validate(j)) {
|
|
do {
|
|
j2 = get();
|
|
if ((j2 & Long.MIN_VALUE) != 0) {
|
|
if (compareAndSet(Long.MIN_VALUE, -9223372036854775807L)) {
|
|
this.downstream.onNext(this.value);
|
|
this.downstream.onComplete();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
} while (!compareAndSet(j2, BackpressureHelper.addCap(j2, j)));
|
|
this.upstream.request(j);
|
|
}
|
|
}
|
|
|
|
public void onDrop(R r) {
|
|
}
|
|
}
|