Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
package io.reactivex.internal.subscribers;
import io.reactivex.FlowableSubscriber;
import io.reactivex.internal.subscriptions.SubscriptionHelper;
import io.reactivex.internal.util.NotificationLite;
import java.util.Queue;
import java.util.concurrent.atomic.AtomicReference;
import org.reactivestreams.Subscription;
/* loaded from: classes2.dex */
public final class BlockingSubscriber<T> extends AtomicReference<Subscription> implements FlowableSubscriber<T>, Subscription {
public static final Object TERMINATED = new Object();
private static final long serialVersionUID = -4875965440900746268L;
final Queue<Object> queue;
public BlockingSubscriber(Queue<Object> queue) {
this.queue = queue;
}
@Override // org.reactivestreams.Subscription
public void cancel() {
if (SubscriptionHelper.cancel(this)) {
this.queue.offer(TERMINATED);
}
}
public boolean isCancelled() {
return get() == SubscriptionHelper.CANCELLED;
}
@Override // org.reactivestreams.Subscriber
public void onComplete() {
this.queue.offer(NotificationLite.complete());
}
@Override // org.reactivestreams.Subscriber
public void onError(Throwable th) {
this.queue.offer(NotificationLite.error(th));
}
@Override // org.reactivestreams.Subscriber
public void onNext(T t) {
this.queue.offer(NotificationLite.next(t));
}
@Override // org.reactivestreams.Subscriber
public void onSubscribe(Subscription subscription) {
if (SubscriptionHelper.setOnce(this, subscription)) {
this.queue.offer(NotificationLite.subscription(this));
}
}
@Override // org.reactivestreams.Subscription
public void request(long j) {
get().request(j);
}
}

View File

@@ -0,0 +1,124 @@
package io.reactivex.internal.subscribers;
import io.reactivex.FlowableSubscriber;
import io.reactivex.disposables.Disposable;
import io.reactivex.exceptions.CompositeException;
import io.reactivex.exceptions.Exceptions;
import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;
import io.reactivex.internal.functions.Functions;
import io.reactivex.internal.subscriptions.SubscriptionHelper;
import io.reactivex.observers.LambdaConsumerIntrospection;
import io.reactivex.plugins.RxJavaPlugins;
import java.util.concurrent.atomic.AtomicReference;
import org.reactivestreams.Subscription;
/* loaded from: classes2.dex */
public final class BoundedSubscriber<T> extends AtomicReference<Subscription> implements FlowableSubscriber<T>, Subscription, Disposable, LambdaConsumerIntrospection {
private static final long serialVersionUID = -7251123623727029452L;
final int bufferSize;
int consumed;
final int limit;
final Action onComplete;
final Consumer<? super Throwable> onError;
final Consumer<? super T> onNext;
final Consumer<? super Subscription> onSubscribe;
public BoundedSubscriber(Consumer<? super T> consumer, Consumer<? super Throwable> consumer2, Action action, Consumer<? super Subscription> consumer3, int i) {
this.onNext = consumer;
this.onError = consumer2;
this.onComplete = action;
this.onSubscribe = consumer3;
this.bufferSize = i;
this.limit = i - (i >> 2);
}
@Override // org.reactivestreams.Subscription
public void cancel() {
SubscriptionHelper.cancel(this);
}
@Override // io.reactivex.disposables.Disposable
public void dispose() {
cancel();
}
public boolean hasCustomOnError() {
return this.onError != Functions.e;
}
public boolean isDisposed() {
return get() == SubscriptionHelper.CANCELLED;
}
@Override // org.reactivestreams.Subscriber
public void onComplete() {
Subscription subscription = get();
SubscriptionHelper subscriptionHelper = SubscriptionHelper.CANCELLED;
if (subscription != subscriptionHelper) {
lazySet(subscriptionHelper);
try {
this.onComplete.run();
} catch (Throwable th) {
Exceptions.b(th);
RxJavaPlugins.b(th);
}
}
}
@Override // org.reactivestreams.Subscriber
public void onError(Throwable th) {
Subscription subscription = get();
SubscriptionHelper subscriptionHelper = SubscriptionHelper.CANCELLED;
if (subscription == subscriptionHelper) {
RxJavaPlugins.b(th);
return;
}
lazySet(subscriptionHelper);
try {
this.onError.accept(th);
} catch (Throwable th2) {
Exceptions.b(th2);
RxJavaPlugins.b(new CompositeException(th, th2));
}
}
@Override // org.reactivestreams.Subscriber
public void onNext(T t) {
if (isDisposed()) {
return;
}
try {
this.onNext.accept(t);
int i = this.consumed + 1;
if (i == this.limit) {
this.consumed = 0;
get().request(this.limit);
} else {
this.consumed = i;
}
} catch (Throwable th) {
Exceptions.b(th);
get().cancel();
onError(th);
}
}
@Override // org.reactivestreams.Subscriber
public void onSubscribe(Subscription subscription) {
if (SubscriptionHelper.setOnce(this, subscription)) {
try {
this.onSubscribe.accept(this);
} catch (Throwable th) {
Exceptions.b(th);
subscription.cancel();
onError(th);
}
}
}
@Override // org.reactivestreams.Subscription
public void request(long j) {
get().request(j);
}
}

View File

@@ -0,0 +1,48 @@
package io.reactivex.internal.subscribers;
import io.reactivex.FlowableSubscriber;
import io.reactivex.internal.subscriptions.DeferredScalarSubscription;
import io.reactivex.internal.subscriptions.SubscriptionHelper;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
/* loaded from: classes2.dex */
public abstract class DeferredScalarSubscriber<T, R> extends DeferredScalarSubscription<R> implements FlowableSubscriber<T> {
private static final long serialVersionUID = 2984505488220891551L;
protected boolean hasValue;
protected Subscription upstream;
public DeferredScalarSubscriber(Subscriber<? super R> subscriber) {
super(subscriber);
}
@Override // io.reactivex.internal.subscriptions.DeferredScalarSubscription, org.reactivestreams.Subscription
public void cancel() {
super.cancel();
this.upstream.cancel();
}
@Override // org.reactivestreams.Subscriber
public void onComplete() {
if (this.hasValue) {
complete(this.value);
} else {
this.downstream.onComplete();
}
}
@Override // org.reactivestreams.Subscriber
public void onError(Throwable th) {
this.value = null;
this.downstream.onError(th);
}
@Override // org.reactivestreams.Subscriber
public void onSubscribe(Subscription subscription) {
if (SubscriptionHelper.validate(this.upstream, subscription)) {
this.upstream = subscription;
this.downstream.onSubscribe(this);
subscription.request(Long.MAX_VALUE);
}
}
}

View File

@@ -0,0 +1,89 @@
package io.reactivex.internal.subscribers;
import io.reactivex.FlowableSubscriber;
import io.reactivex.disposables.Disposable;
import io.reactivex.exceptions.CompositeException;
import io.reactivex.exceptions.Exceptions;
import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;
import io.reactivex.functions.Predicate;
import io.reactivex.internal.subscriptions.SubscriptionHelper;
import io.reactivex.plugins.RxJavaPlugins;
import java.util.concurrent.atomic.AtomicReference;
import org.reactivestreams.Subscription;
/* loaded from: classes2.dex */
public final class ForEachWhileSubscriber<T> extends AtomicReference<Subscription> implements FlowableSubscriber<T>, Disposable {
private static final long serialVersionUID = -4403180040475402120L;
boolean done;
final Action onComplete;
final Consumer<? super Throwable> onError;
final Predicate<? super T> onNext;
public ForEachWhileSubscriber(Predicate<? super T> predicate, Consumer<? super Throwable> consumer, Action action) {
this.onNext = predicate;
this.onError = consumer;
this.onComplete = action;
}
@Override // io.reactivex.disposables.Disposable
public void dispose() {
SubscriptionHelper.cancel(this);
}
public boolean isDisposed() {
return SubscriptionHelper.isCancelled(get());
}
@Override // org.reactivestreams.Subscriber
public void onComplete() {
if (this.done) {
return;
}
this.done = true;
try {
this.onComplete.run();
} catch (Throwable th) {
Exceptions.b(th);
RxJavaPlugins.b(th);
}
}
@Override // org.reactivestreams.Subscriber
public void onError(Throwable th) {
if (this.done) {
RxJavaPlugins.b(th);
return;
}
this.done = true;
try {
this.onError.accept(th);
} catch (Throwable th2) {
Exceptions.b(th2);
RxJavaPlugins.b(new CompositeException(th, th2));
}
}
@Override // org.reactivestreams.Subscriber
public void onNext(T t) {
if (this.done) {
return;
}
try {
if (this.onNext.a(t)) {
return;
}
dispose();
onComplete();
} catch (Throwable th) {
Exceptions.b(th);
dispose();
onError(th);
}
}
@Override // org.reactivestreams.Subscriber
public void onSubscribe(Subscription subscription) {
SubscriptionHelper.setOnce(this, subscription, Long.MAX_VALUE);
}
}

View File

@@ -0,0 +1,113 @@
package io.reactivex.internal.subscribers;
import io.reactivex.FlowableSubscriber;
import io.reactivex.internal.fuseable.QueueSubscription;
import io.reactivex.internal.fuseable.SimpleQueue;
import io.reactivex.internal.subscriptions.SubscriptionHelper;
import io.reactivex.internal.util.QueueDrainHelper;
import java.util.concurrent.atomic.AtomicReference;
import org.reactivestreams.Subscription;
/* loaded from: classes2.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.a(this);
}
@Override // org.reactivestreams.Subscriber
public void onError(Throwable th) {
this.parent.a((InnerQueuedSubscriber) this, th);
}
@Override // org.reactivestreams.Subscriber
public void onNext(T t) {
if (this.fusionMode == 0) {
this.parent.a((InnerQueuedSubscriber<InnerQueuedSubscriber<T>>) this, (InnerQueuedSubscriber<T>) t);
} else {
this.parent.a();
}
}
@Override // 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.a(this);
return;
}
if (requestFusion == 2) {
this.fusionMode = requestFusion;
this.queue = queueSubscription;
QueueDrainHelper.a(subscription, this.prefetch);
return;
}
}
this.queue = QueueDrainHelper.a(this.prefetch);
QueueDrainHelper.a(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 requestOne() {
if (this.fusionMode != 1) {
long j = this.produced + 1;
if (j != this.limit) {
this.produced = j;
} else {
this.produced = 0L;
get().request(j);
}
}
}
public void setDone() {
this.done = true;
}
}

View File

@@ -0,0 +1,12 @@
package io.reactivex.internal.subscribers;
/* loaded from: classes2.dex */
public interface InnerQueuedSubscriberSupport<T> {
void a();
void a(InnerQueuedSubscriber<T> innerQueuedSubscriber);
void a(InnerQueuedSubscriber<T> innerQueuedSubscriber, T t);
void a(InnerQueuedSubscriber<T> innerQueuedSubscriber, Throwable th);
}

View File

@@ -0,0 +1,112 @@
package io.reactivex.internal.subscribers;
import io.reactivex.FlowableSubscriber;
import io.reactivex.disposables.Disposable;
import io.reactivex.exceptions.CompositeException;
import io.reactivex.exceptions.Exceptions;
import io.reactivex.functions.Action;
import io.reactivex.functions.Consumer;
import io.reactivex.internal.functions.Functions;
import io.reactivex.internal.subscriptions.SubscriptionHelper;
import io.reactivex.observers.LambdaConsumerIntrospection;
import io.reactivex.plugins.RxJavaPlugins;
import java.util.concurrent.atomic.AtomicReference;
import org.reactivestreams.Subscription;
/* loaded from: classes2.dex */
public final class LambdaSubscriber<T> extends AtomicReference<Subscription> implements FlowableSubscriber<T>, Subscription, Disposable, LambdaConsumerIntrospection {
private static final long serialVersionUID = -7251123623727029452L;
final Action onComplete;
final Consumer<? super Throwable> onError;
final Consumer<? super T> onNext;
final Consumer<? super Subscription> onSubscribe;
public LambdaSubscriber(Consumer<? super T> consumer, Consumer<? super Throwable> consumer2, Action action, Consumer<? super Subscription> consumer3) {
this.onNext = consumer;
this.onError = consumer2;
this.onComplete = action;
this.onSubscribe = consumer3;
}
@Override // org.reactivestreams.Subscription
public void cancel() {
SubscriptionHelper.cancel(this);
}
@Override // io.reactivex.disposables.Disposable
public void dispose() {
cancel();
}
public boolean hasCustomOnError() {
return this.onError != Functions.e;
}
public boolean isDisposed() {
return get() == SubscriptionHelper.CANCELLED;
}
@Override // org.reactivestreams.Subscriber
public void onComplete() {
Subscription subscription = get();
SubscriptionHelper subscriptionHelper = SubscriptionHelper.CANCELLED;
if (subscription != subscriptionHelper) {
lazySet(subscriptionHelper);
try {
this.onComplete.run();
} catch (Throwable th) {
Exceptions.b(th);
RxJavaPlugins.b(th);
}
}
}
@Override // org.reactivestreams.Subscriber
public void onError(Throwable th) {
Subscription subscription = get();
SubscriptionHelper subscriptionHelper = SubscriptionHelper.CANCELLED;
if (subscription == subscriptionHelper) {
RxJavaPlugins.b(th);
return;
}
lazySet(subscriptionHelper);
try {
this.onError.accept(th);
} catch (Throwable th2) {
Exceptions.b(th2);
RxJavaPlugins.b(new CompositeException(th, th2));
}
}
@Override // org.reactivestreams.Subscriber
public void onNext(T t) {
if (isDisposed()) {
return;
}
try {
this.onNext.accept(t);
} catch (Throwable th) {
Exceptions.b(th);
get().cancel();
onError(th);
}
}
@Override // org.reactivestreams.Subscriber
public void onSubscribe(Subscription subscription) {
if (SubscriptionHelper.setOnce(this, subscription)) {
try {
this.onSubscribe.accept(this);
} catch (Throwable th) {
Exceptions.b(th);
subscription.cancel();
onError(th);
}
}
}
@Override // org.reactivestreams.Subscription
public void request(long j) {
get().request(j);
}
}

View File

@@ -0,0 +1,85 @@
package io.reactivex.internal.subscribers;
import io.reactivex.FlowableSubscriber;
import io.reactivex.internal.subscriptions.SubscriptionHelper;
import io.reactivex.internal.util.BackpressureHelper;
import java.util.concurrent.atomic.AtomicLong;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
/* loaded from: classes2.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;
}
@Override // org.reactivestreams.Subscription
public void cancel() {
this.upstream.cancel();
}
protected final void complete(R r) {
long j = this.produced;
if (j != 0) {
BackpressureHelper.b(this, j);
}
while (true) {
long j2 = get();
if ((j2 & COMPLETE_MASK) != 0) {
onDrop(r);
return;
}
if ((j2 & REQUEST_MASK) != 0) {
lazySet(-9223372036854775807L);
this.downstream.onNext(r);
this.downstream.onComplete();
return;
} else {
this.value = r;
if (compareAndSet(0L, COMPLETE_MASK)) {
return;
} else {
this.value = null;
}
}
}
}
protected void onDrop(R r) {
}
@Override // 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 & COMPLETE_MASK) != 0) {
if (compareAndSet(COMPLETE_MASK, -9223372036854775807L)) {
this.downstream.onNext(this.value);
this.downstream.onComplete();
return;
}
return;
}
} while (!compareAndSet(j2, BackpressureHelper.a(j2, j)));
this.upstream.request(j);
}
}
}

View File

@@ -0,0 +1,74 @@
package io.reactivex.internal.subscribers;
import io.reactivex.FlowableSubscriber;
import io.reactivex.internal.subscriptions.SubscriptionHelper;
import io.reactivex.internal.util.AtomicThrowable;
import io.reactivex.internal.util.HalfSerializer;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
/* loaded from: classes2.dex */
public class StrictSubscriber<T> extends AtomicInteger implements FlowableSubscriber<T>, Subscription {
private static final long serialVersionUID = -4945028590049415624L;
volatile boolean done;
final Subscriber<? super T> downstream;
final AtomicThrowable error = new AtomicThrowable();
final AtomicLong requested = new AtomicLong();
final AtomicReference<Subscription> upstream = new AtomicReference<>();
final AtomicBoolean once = new AtomicBoolean();
public StrictSubscriber(Subscriber<? super T> subscriber) {
this.downstream = subscriber;
}
@Override // org.reactivestreams.Subscription
public void cancel() {
if (this.done) {
return;
}
SubscriptionHelper.cancel(this.upstream);
}
@Override // org.reactivestreams.Subscriber
public void onComplete() {
this.done = true;
HalfSerializer.a(this.downstream, this, this.error);
}
@Override // org.reactivestreams.Subscriber
public void onError(Throwable th) {
this.done = true;
HalfSerializer.a((Subscriber<?>) this.downstream, th, (AtomicInteger) this, this.error);
}
@Override // org.reactivestreams.Subscriber
public void onNext(T t) {
HalfSerializer.a(this.downstream, t, this, this.error);
}
@Override // org.reactivestreams.Subscriber
public void onSubscribe(Subscription subscription) {
if (this.once.compareAndSet(false, true)) {
this.downstream.onSubscribe(this);
SubscriptionHelper.deferredSetOnce(this.upstream, this.requested, subscription);
} else {
subscription.cancel();
cancel();
onError(new IllegalStateException("§2.12 violated: onSubscribe must be called at most once"));
}
}
@Override // org.reactivestreams.Subscription
public void request(long j) {
if (j > 0) {
SubscriptionHelper.deferredRequest(this.upstream, this.requested, j);
return;
}
cancel();
onError(new IllegalArgumentException("§3.9 violated: positive request amount required but it was " + j));
}
}

View File

@@ -0,0 +1,70 @@
package io.reactivex.internal.subscribers;
import io.reactivex.FlowableSubscriber;
import io.reactivex.disposables.Disposable;
import io.reactivex.internal.disposables.DisposableHelper;
import io.reactivex.internal.subscriptions.SubscriptionHelper;
import java.util.concurrent.atomic.AtomicReference;
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;
/* loaded from: classes2.dex */
public final class SubscriberResourceWrapper<T> extends AtomicReference<Disposable> implements FlowableSubscriber<T>, Disposable, Subscription {
private static final long serialVersionUID = -8612022020200669122L;
final Subscriber<? super T> downstream;
final AtomicReference<Subscription> upstream = new AtomicReference<>();
public SubscriberResourceWrapper(Subscriber<? super T> subscriber) {
this.downstream = subscriber;
}
@Override // org.reactivestreams.Subscription
public void cancel() {
dispose();
}
@Override // io.reactivex.disposables.Disposable
public void dispose() {
SubscriptionHelper.cancel(this.upstream);
DisposableHelper.dispose(this);
}
public boolean isDisposed() {
return this.upstream.get() == SubscriptionHelper.CANCELLED;
}
@Override // org.reactivestreams.Subscriber
public void onComplete() {
DisposableHelper.dispose(this);
this.downstream.onComplete();
}
@Override // org.reactivestreams.Subscriber
public void onError(Throwable th) {
DisposableHelper.dispose(this);
this.downstream.onError(th);
}
@Override // org.reactivestreams.Subscriber
public void onNext(T t) {
this.downstream.onNext(t);
}
@Override // org.reactivestreams.Subscriber
public void onSubscribe(Subscription subscription) {
if (SubscriptionHelper.setOnce(this.upstream, subscription)) {
this.downstream.onSubscribe(this);
}
}
@Override // org.reactivestreams.Subscription
public void request(long j) {
if (SubscriptionHelper.validate(j)) {
this.upstream.get().request(j);
}
}
public void setResource(Disposable disposable) {
DisposableHelper.set(this, disposable);
}
}