72 lines
1.8 KiB
Java
72 lines
1.8 KiB
Java
package io.reactivex.internal.observers;
|
|
|
|
import io.reactivex.CompletableObserver;
|
|
import io.reactivex.MaybeObserver;
|
|
import io.reactivex.SingleObserver;
|
|
import io.reactivex.disposables.Disposable;
|
|
import io.reactivex.internal.util.BlockingHelper;
|
|
import io.reactivex.internal.util.ExceptionHelper;
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public final class BlockingMultiObserver<T> extends CountDownLatch implements SingleObserver<T>, CompletableObserver, MaybeObserver<T> {
|
|
T a;
|
|
Throwable b;
|
|
Disposable c;
|
|
volatile boolean d;
|
|
|
|
public BlockingMultiObserver() {
|
|
super(1);
|
|
}
|
|
|
|
public T a() {
|
|
if (getCount() != 0) {
|
|
try {
|
|
BlockingHelper.a();
|
|
await();
|
|
} catch (InterruptedException e) {
|
|
b();
|
|
throw ExceptionHelper.a(e);
|
|
}
|
|
}
|
|
Throwable th = this.b;
|
|
if (th == null) {
|
|
return this.a;
|
|
}
|
|
throw ExceptionHelper.a(th);
|
|
}
|
|
|
|
void b() {
|
|
this.d = true;
|
|
Disposable disposable = this.c;
|
|
if (disposable != null) {
|
|
disposable.dispose();
|
|
}
|
|
}
|
|
|
|
@Override // io.reactivex.CompletableObserver, io.reactivex.MaybeObserver
|
|
public void onComplete() {
|
|
countDown();
|
|
}
|
|
|
|
@Override // io.reactivex.SingleObserver
|
|
public void onError(Throwable th) {
|
|
this.b = th;
|
|
countDown();
|
|
}
|
|
|
|
@Override // io.reactivex.SingleObserver
|
|
public void onSubscribe(Disposable disposable) {
|
|
this.c = disposable;
|
|
if (this.d) {
|
|
disposable.dispose();
|
|
}
|
|
}
|
|
|
|
@Override // io.reactivex.SingleObserver
|
|
public void onSuccess(T t) {
|
|
this.a = t;
|
|
countDown();
|
|
}
|
|
}
|