mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-17 19:37:18 +01:00
62 lines
2.1 KiB
Java
62 lines
2.1 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.BlockingHelper;
|
|
import io.reactivex.rxjava3.internal.util.ExceptionHelper;
|
|
import java.util.concurrent.CountDownLatch;
|
|
import org.reactivestreams.Subscription;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes10.dex */
|
|
public abstract class BlockingBaseSubscriber<T> extends CountDownLatch implements FlowableSubscriber<T> {
|
|
volatile boolean cancelled;
|
|
Throwable error;
|
|
Subscription upstream;
|
|
T value;
|
|
|
|
public BlockingBaseSubscriber() {
|
|
super(1);
|
|
}
|
|
|
|
public final T blockingGet() {
|
|
if (getCount() != 0) {
|
|
try {
|
|
BlockingHelper.verifyNonBlocking();
|
|
await();
|
|
} catch (InterruptedException e) {
|
|
Subscription subscription = this.upstream;
|
|
this.upstream = SubscriptionHelper.CANCELLED;
|
|
if (subscription != null) {
|
|
subscription.cancel();
|
|
}
|
|
throw ExceptionHelper.wrapOrThrow(e);
|
|
}
|
|
}
|
|
Throwable th = this.error;
|
|
if (th == null) {
|
|
return this.value;
|
|
}
|
|
throw ExceptionHelper.wrapOrThrow(th);
|
|
}
|
|
|
|
@Override // org.reactivestreams.Subscriber
|
|
public final void onComplete() {
|
|
countDown();
|
|
}
|
|
|
|
@Override // io.reactivex.rxjava3.core.FlowableSubscriber, org.reactivestreams.Subscriber
|
|
public final void onSubscribe(Subscription subscription) {
|
|
if (SubscriptionHelper.validate(this.upstream, subscription)) {
|
|
this.upstream = subscription;
|
|
if (this.cancelled) {
|
|
return;
|
|
}
|
|
subscription.request(Long.MAX_VALUE);
|
|
if (this.cancelled) {
|
|
this.upstream = SubscriptionHelper.CANCELLED;
|
|
subscription.cancel();
|
|
}
|
|
}
|
|
}
|
|
}
|