mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-15 02:17:18 +01:00
83 lines
3.2 KiB
Java
83 lines
3.2 KiB
Java
package io.reactivex.rxjava3.internal.util;
|
|
|
|
import defpackage.a$$ExternalSyntheticOutline0;
|
|
import io.reactivex.rxjava3.disposables.Disposable;
|
|
import io.reactivex.rxjava3.exceptions.ProtocolViolationException;
|
|
import io.reactivex.rxjava3.internal.disposables.DisposableHelper;
|
|
import io.reactivex.rxjava3.internal.subscriptions.SubscriptionHelper;
|
|
import io.reactivex.rxjava3.plugins.RxJavaPlugins;
|
|
import java.util.Objects;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import org.reactivestreams.Subscription;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes10.dex */
|
|
public final class EndConsumerHelper {
|
|
private EndConsumerHelper() {
|
|
throw new IllegalStateException("No instances!");
|
|
}
|
|
|
|
public static String composeMessage(String str) {
|
|
return a$$ExternalSyntheticOutline0.m("It is not allowed to subscribe with a(n) ", str, " multiple times. Please create a fresh instance of ", str, " and subscribe that to the target source instead.");
|
|
}
|
|
|
|
public static void reportDoubleSubscription(Class<?> cls) {
|
|
RxJavaPlugins.onError(new ProtocolViolationException(composeMessage(cls.getName())));
|
|
}
|
|
|
|
public static boolean setOnce(AtomicReference<Disposable> atomicReference, Disposable disposable, Class<?> cls) {
|
|
Objects.requireNonNull(disposable, "next is null");
|
|
while (!atomicReference.compareAndSet(null, disposable)) {
|
|
if (atomicReference.get() != null) {
|
|
disposable.dispose();
|
|
if (atomicReference.get() == DisposableHelper.DISPOSED) {
|
|
return false;
|
|
}
|
|
reportDoubleSubscription(cls);
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public static boolean validate(Disposable disposable, Disposable disposable2, Class<?> cls) {
|
|
Objects.requireNonNull(disposable2, "next is null");
|
|
if (disposable == null) {
|
|
return true;
|
|
}
|
|
disposable2.dispose();
|
|
if (disposable == DisposableHelper.DISPOSED) {
|
|
return false;
|
|
}
|
|
reportDoubleSubscription(cls);
|
|
return false;
|
|
}
|
|
|
|
public static boolean validate(Subscription subscription, Subscription subscription2, Class<?> cls) {
|
|
Objects.requireNonNull(subscription2, "next is null");
|
|
if (subscription == null) {
|
|
return true;
|
|
}
|
|
subscription2.cancel();
|
|
if (subscription == SubscriptionHelper.CANCELLED) {
|
|
return false;
|
|
}
|
|
reportDoubleSubscription(cls);
|
|
return false;
|
|
}
|
|
|
|
public static boolean setOnce(AtomicReference<Subscription> atomicReference, Subscription subscription, Class<?> cls) {
|
|
Objects.requireNonNull(subscription, "next is null");
|
|
while (!atomicReference.compareAndSet(null, subscription)) {
|
|
if (atomicReference.get() != null) {
|
|
subscription.cancel();
|
|
if (atomicReference.get() == SubscriptionHelper.CANCELLED) {
|
|
return false;
|
|
}
|
|
reportDoubleSubscription(cls);
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|