mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-15 10:27:17 +01:00
77 lines
2.3 KiB
Java
77 lines
2.3 KiB
Java
package io.reactivex.rxjava3.internal.subscriptions;
|
|
|
|
import io.reactivex.rxjava3.annotations.Nullable;
|
|
import io.reactivex.rxjava3.operators.QueueSubscription;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import org.reactivestreams.Subscriber;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes10.dex */
|
|
public final class ScalarSubscription<T> extends AtomicInteger implements QueueSubscription<T> {
|
|
static final int CANCELLED = 2;
|
|
static final int NO_REQUEST = 0;
|
|
static final int REQUESTED = 1;
|
|
private static final long serialVersionUID = -3830916580126663321L;
|
|
final Subscriber<? super T> subscriber;
|
|
final T value;
|
|
|
|
public ScalarSubscription(Subscriber<? super T> subscriber, T t) {
|
|
this.subscriber = subscriber;
|
|
this.value = t;
|
|
}
|
|
|
|
@Override // org.reactivestreams.Subscription
|
|
public void cancel() {
|
|
lazySet(2);
|
|
}
|
|
|
|
@Override // io.reactivex.rxjava3.operators.SimpleQueue
|
|
public void clear() {
|
|
lazySet(1);
|
|
}
|
|
|
|
public boolean isCancelled() {
|
|
return get() == 2;
|
|
}
|
|
|
|
@Override // io.reactivex.rxjava3.operators.SimpleQueue
|
|
public boolean isEmpty() {
|
|
return get() != 0;
|
|
}
|
|
|
|
@Override // io.reactivex.rxjava3.operators.SimpleQueue
|
|
public boolean offer(T t) {
|
|
throw new UnsupportedOperationException("Should not be called!");
|
|
}
|
|
|
|
@Override // io.reactivex.rxjava3.operators.SimpleQueue
|
|
@Nullable
|
|
public T poll() {
|
|
if (get() != 0) {
|
|
return null;
|
|
}
|
|
lazySet(1);
|
|
return this.value;
|
|
}
|
|
|
|
@Override // org.reactivestreams.Subscription
|
|
public void request(long j) {
|
|
if (SubscriptionHelper.validate(j) && compareAndSet(0, 1)) {
|
|
Subscriber<? super T> subscriber = this.subscriber;
|
|
subscriber.onNext(this.value);
|
|
if (get() != 2) {
|
|
subscriber.onComplete();
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // io.reactivex.rxjava3.operators.QueueFuseable
|
|
public int requestFusion(int i) {
|
|
return i & 1;
|
|
}
|
|
|
|
@Override // io.reactivex.rxjava3.operators.SimpleQueue
|
|
public boolean offer(T t, T t2) {
|
|
throw new UnsupportedOperationException("Should not be called!");
|
|
}
|
|
}
|