Initial commit
This commit is contained in:
@@ -0,0 +1,248 @@
|
||||
package io.reactivex.internal.operators.mixed;
|
||||
|
||||
import io.reactivex.Completable;
|
||||
import io.reactivex.CompletableObserver;
|
||||
import io.reactivex.CompletableSource;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.exceptions.Exceptions;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.internal.disposables.DisposableHelper;
|
||||
import io.reactivex.internal.functions.ObjectHelper;
|
||||
import io.reactivex.internal.fuseable.QueueDisposable;
|
||||
import io.reactivex.internal.fuseable.SimpleQueue;
|
||||
import io.reactivex.internal.queue.SpscLinkedArrayQueue;
|
||||
import io.reactivex.internal.util.AtomicThrowable;
|
||||
import io.reactivex.internal.util.ErrorMode;
|
||||
import io.reactivex.internal.util.ExceptionHelper;
|
||||
import io.reactivex.plugins.RxJavaPlugins;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class ObservableConcatMapCompletable<T> extends Completable {
|
||||
final Observable<T> a;
|
||||
final Function<? super T, ? extends CompletableSource> b;
|
||||
final ErrorMode c;
|
||||
final int d;
|
||||
|
||||
public ObservableConcatMapCompletable(Observable<T> observable, Function<? super T, ? extends CompletableSource> function, ErrorMode errorMode, int i) {
|
||||
this.a = observable;
|
||||
this.b = function;
|
||||
this.c = errorMode;
|
||||
this.d = i;
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Completable
|
||||
protected void b(CompletableObserver completableObserver) {
|
||||
if (ScalarXMapZHelper.a(this.a, this.b, completableObserver)) {
|
||||
return;
|
||||
}
|
||||
this.a.subscribe(new ConcatMapCompletableObserver(completableObserver, this.b, this.c, this.d));
|
||||
}
|
||||
|
||||
static final class ConcatMapCompletableObserver<T> extends AtomicInteger implements Observer<T>, Disposable {
|
||||
final CompletableObserver a;
|
||||
final Function<? super T, ? extends CompletableSource> b;
|
||||
final ErrorMode c;
|
||||
final AtomicThrowable d = new AtomicThrowable();
|
||||
final ConcatMapInnerObserver e = new ConcatMapInnerObserver(this);
|
||||
final int f;
|
||||
SimpleQueue<T> g;
|
||||
Disposable h;
|
||||
volatile boolean i;
|
||||
volatile boolean j;
|
||||
volatile boolean k;
|
||||
|
||||
static final class ConcatMapInnerObserver extends AtomicReference<Disposable> implements CompletableObserver {
|
||||
final ConcatMapCompletableObserver<?> a;
|
||||
|
||||
ConcatMapInnerObserver(ConcatMapCompletableObserver<?> concatMapCompletableObserver) {
|
||||
this.a = concatMapCompletableObserver;
|
||||
}
|
||||
|
||||
void a() {
|
||||
DisposableHelper.dispose(this);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.CompletableObserver, io.reactivex.MaybeObserver
|
||||
public void onComplete() {
|
||||
this.a.b();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.CompletableObserver
|
||||
public void onError(Throwable th) {
|
||||
this.a.a(th);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.CompletableObserver
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
DisposableHelper.replace(this, disposable);
|
||||
}
|
||||
}
|
||||
|
||||
ConcatMapCompletableObserver(CompletableObserver completableObserver, Function<? super T, ? extends CompletableSource> function, ErrorMode errorMode, int i) {
|
||||
this.a = completableObserver;
|
||||
this.b = function;
|
||||
this.c = errorMode;
|
||||
this.f = i;
|
||||
}
|
||||
|
||||
void a(Throwable th) {
|
||||
if (!this.d.addThrowable(th)) {
|
||||
RxJavaPlugins.b(th);
|
||||
return;
|
||||
}
|
||||
if (this.c != ErrorMode.IMMEDIATE) {
|
||||
this.i = false;
|
||||
a();
|
||||
return;
|
||||
}
|
||||
this.k = true;
|
||||
this.h.dispose();
|
||||
Throwable terminate = this.d.terminate();
|
||||
if (terminate != ExceptionHelper.a) {
|
||||
this.a.onError(terminate);
|
||||
}
|
||||
if (getAndIncrement() == 0) {
|
||||
this.g.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void b() {
|
||||
this.i = false;
|
||||
a();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.disposables.Disposable
|
||||
public void dispose() {
|
||||
this.k = true;
|
||||
this.h.dispose();
|
||||
this.e.a();
|
||||
if (getAndIncrement() == 0) {
|
||||
this.g.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onComplete() {
|
||||
this.j = true;
|
||||
a();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onError(Throwable th) {
|
||||
if (!this.d.addThrowable(th)) {
|
||||
RxJavaPlugins.b(th);
|
||||
return;
|
||||
}
|
||||
if (this.c != ErrorMode.IMMEDIATE) {
|
||||
this.j = true;
|
||||
a();
|
||||
return;
|
||||
}
|
||||
this.k = true;
|
||||
this.e.a();
|
||||
Throwable terminate = this.d.terminate();
|
||||
if (terminate != ExceptionHelper.a) {
|
||||
this.a.onError(terminate);
|
||||
}
|
||||
if (getAndIncrement() == 0) {
|
||||
this.g.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onNext(T t) {
|
||||
if (t != null) {
|
||||
this.g.offer(t);
|
||||
}
|
||||
a();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
if (DisposableHelper.validate(this.h, disposable)) {
|
||||
this.h = disposable;
|
||||
if (disposable instanceof QueueDisposable) {
|
||||
QueueDisposable queueDisposable = (QueueDisposable) disposable;
|
||||
int requestFusion = queueDisposable.requestFusion(3);
|
||||
if (requestFusion == 1) {
|
||||
this.g = queueDisposable;
|
||||
this.j = true;
|
||||
this.a.onSubscribe(this);
|
||||
a();
|
||||
return;
|
||||
}
|
||||
if (requestFusion == 2) {
|
||||
this.g = queueDisposable;
|
||||
this.a.onSubscribe(this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.g = new SpscLinkedArrayQueue(this.f);
|
||||
this.a.onSubscribe(this);
|
||||
}
|
||||
}
|
||||
|
||||
void a() {
|
||||
boolean z;
|
||||
if (getAndIncrement() != 0) {
|
||||
return;
|
||||
}
|
||||
AtomicThrowable atomicThrowable = this.d;
|
||||
ErrorMode errorMode = this.c;
|
||||
while (!this.k) {
|
||||
if (!this.i) {
|
||||
if (errorMode == ErrorMode.BOUNDARY && atomicThrowable.get() != null) {
|
||||
this.k = true;
|
||||
this.g.clear();
|
||||
this.a.onError(atomicThrowable.terminate());
|
||||
return;
|
||||
}
|
||||
boolean z2 = this.j;
|
||||
CompletableSource completableSource = null;
|
||||
try {
|
||||
T poll = this.g.poll();
|
||||
if (poll != null) {
|
||||
CompletableSource apply = this.b.apply(poll);
|
||||
ObjectHelper.a(apply, "The mapper returned a null CompletableSource");
|
||||
completableSource = apply;
|
||||
z = false;
|
||||
} else {
|
||||
z = true;
|
||||
}
|
||||
if (z2 && z) {
|
||||
this.k = true;
|
||||
Throwable terminate = atomicThrowable.terminate();
|
||||
if (terminate != null) {
|
||||
this.a.onError(terminate);
|
||||
return;
|
||||
} else {
|
||||
this.a.onComplete();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!z) {
|
||||
this.i = true;
|
||||
completableSource.a(this.e);
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
Exceptions.b(th);
|
||||
this.k = true;
|
||||
this.g.clear();
|
||||
this.h.dispose();
|
||||
atomicThrowable.addThrowable(th);
|
||||
this.a.onError(atomicThrowable.terminate());
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (decrementAndGet() == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.g.clear();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,225 @@
|
||||
package io.reactivex.internal.operators.mixed;
|
||||
|
||||
import io.reactivex.MaybeObserver;
|
||||
import io.reactivex.MaybeSource;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.exceptions.Exceptions;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.internal.disposables.DisposableHelper;
|
||||
import io.reactivex.internal.functions.ObjectHelper;
|
||||
import io.reactivex.internal.fuseable.SimplePlainQueue;
|
||||
import io.reactivex.internal.queue.SpscLinkedArrayQueue;
|
||||
import io.reactivex.internal.util.AtomicThrowable;
|
||||
import io.reactivex.internal.util.ErrorMode;
|
||||
import io.reactivex.plugins.RxJavaPlugins;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class ObservableConcatMapMaybe<T, R> extends Observable<R> {
|
||||
final Observable<T> a;
|
||||
final Function<? super T, ? extends MaybeSource<? extends R>> b;
|
||||
final ErrorMode c;
|
||||
final int d;
|
||||
|
||||
public ObservableConcatMapMaybe(Observable<T> observable, Function<? super T, ? extends MaybeSource<? extends R>> function, ErrorMode errorMode, int i) {
|
||||
this.a = observable;
|
||||
this.b = function;
|
||||
this.c = errorMode;
|
||||
this.d = i;
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observable
|
||||
protected void subscribeActual(Observer<? super R> observer) {
|
||||
if (ScalarXMapZHelper.a(this.a, this.b, observer)) {
|
||||
return;
|
||||
}
|
||||
this.a.subscribe(new ConcatMapMaybeMainObserver(observer, this.b, this.d, this.c));
|
||||
}
|
||||
|
||||
static final class ConcatMapMaybeMainObserver<T, R> extends AtomicInteger implements Observer<T>, Disposable {
|
||||
final Observer<? super R> a;
|
||||
final Function<? super T, ? extends MaybeSource<? extends R>> b;
|
||||
final AtomicThrowable c = new AtomicThrowable();
|
||||
final ConcatMapMaybeObserver<R> d = new ConcatMapMaybeObserver<>(this);
|
||||
final SimplePlainQueue<T> e;
|
||||
final ErrorMode f;
|
||||
Disposable g;
|
||||
volatile boolean h;
|
||||
volatile boolean i;
|
||||
R j;
|
||||
volatile int k;
|
||||
|
||||
static final class ConcatMapMaybeObserver<R> extends AtomicReference<Disposable> implements MaybeObserver<R> {
|
||||
final ConcatMapMaybeMainObserver<?, R> a;
|
||||
|
||||
ConcatMapMaybeObserver(ConcatMapMaybeMainObserver<?, R> concatMapMaybeMainObserver) {
|
||||
this.a = concatMapMaybeMainObserver;
|
||||
}
|
||||
|
||||
void a() {
|
||||
DisposableHelper.dispose(this);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.MaybeObserver
|
||||
public void onComplete() {
|
||||
this.a.b();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.MaybeObserver
|
||||
public void onError(Throwable th) {
|
||||
this.a.a(th);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.MaybeObserver
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
DisposableHelper.replace(this, disposable);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.MaybeObserver
|
||||
public void onSuccess(R r) {
|
||||
this.a.a((ConcatMapMaybeMainObserver<?, R>) r);
|
||||
}
|
||||
}
|
||||
|
||||
ConcatMapMaybeMainObserver(Observer<? super R> observer, Function<? super T, ? extends MaybeSource<? extends R>> function, int i, ErrorMode errorMode) {
|
||||
this.a = observer;
|
||||
this.b = function;
|
||||
this.f = errorMode;
|
||||
this.e = new SpscLinkedArrayQueue(i);
|
||||
}
|
||||
|
||||
void a(R r) {
|
||||
this.j = r;
|
||||
this.k = 2;
|
||||
a();
|
||||
}
|
||||
|
||||
void b() {
|
||||
this.k = 0;
|
||||
a();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.disposables.Disposable
|
||||
public void dispose() {
|
||||
this.i = true;
|
||||
this.g.dispose();
|
||||
this.d.a();
|
||||
if (getAndIncrement() == 0) {
|
||||
this.e.clear();
|
||||
this.j = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onComplete() {
|
||||
this.h = true;
|
||||
a();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onError(Throwable th) {
|
||||
if (!this.c.addThrowable(th)) {
|
||||
RxJavaPlugins.b(th);
|
||||
return;
|
||||
}
|
||||
if (this.f == ErrorMode.IMMEDIATE) {
|
||||
this.d.a();
|
||||
}
|
||||
this.h = true;
|
||||
a();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onNext(T t) {
|
||||
this.e.offer(t);
|
||||
a();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
if (DisposableHelper.validate(this.g, disposable)) {
|
||||
this.g = disposable;
|
||||
this.a.onSubscribe(this);
|
||||
}
|
||||
}
|
||||
|
||||
void a(Throwable th) {
|
||||
if (this.c.addThrowable(th)) {
|
||||
if (this.f != ErrorMode.END) {
|
||||
this.g.dispose();
|
||||
}
|
||||
this.k = 0;
|
||||
a();
|
||||
return;
|
||||
}
|
||||
RxJavaPlugins.b(th);
|
||||
}
|
||||
|
||||
void a() {
|
||||
if (getAndIncrement() != 0) {
|
||||
return;
|
||||
}
|
||||
Observer<? super R> observer = this.a;
|
||||
ErrorMode errorMode = this.f;
|
||||
SimplePlainQueue<T> simplePlainQueue = this.e;
|
||||
AtomicThrowable atomicThrowable = this.c;
|
||||
int i = 1;
|
||||
while (true) {
|
||||
if (this.i) {
|
||||
simplePlainQueue.clear();
|
||||
this.j = null;
|
||||
} else {
|
||||
int i2 = this.k;
|
||||
if (atomicThrowable.get() == null || (errorMode != ErrorMode.IMMEDIATE && (errorMode != ErrorMode.BOUNDARY || i2 != 0))) {
|
||||
if (i2 == 0) {
|
||||
boolean z = this.h;
|
||||
T poll = simplePlainQueue.poll();
|
||||
boolean z2 = poll == null;
|
||||
if (z && z2) {
|
||||
Throwable terminate = atomicThrowable.terminate();
|
||||
if (terminate == null) {
|
||||
observer.onComplete();
|
||||
return;
|
||||
} else {
|
||||
observer.onError(terminate);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!z2) {
|
||||
try {
|
||||
MaybeSource<? extends R> apply = this.b.apply(poll);
|
||||
ObjectHelper.a(apply, "The mapper returned a null MaybeSource");
|
||||
MaybeSource<? extends R> maybeSource = apply;
|
||||
this.k = 1;
|
||||
maybeSource.a(this.d);
|
||||
} catch (Throwable th) {
|
||||
Exceptions.b(th);
|
||||
this.g.dispose();
|
||||
simplePlainQueue.clear();
|
||||
atomicThrowable.addThrowable(th);
|
||||
observer.onError(atomicThrowable.terminate());
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (i2 == 2) {
|
||||
R r = this.j;
|
||||
this.j = null;
|
||||
observer.onNext(r);
|
||||
this.k = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
i = addAndGet(-i);
|
||||
if (i == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
simplePlainQueue.clear();
|
||||
this.j = null;
|
||||
observer.onError(atomicThrowable.terminate());
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,215 @@
|
||||
package io.reactivex.internal.operators.mixed;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.SingleSource;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.exceptions.Exceptions;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.internal.disposables.DisposableHelper;
|
||||
import io.reactivex.internal.functions.ObjectHelper;
|
||||
import io.reactivex.internal.fuseable.SimplePlainQueue;
|
||||
import io.reactivex.internal.queue.SpscLinkedArrayQueue;
|
||||
import io.reactivex.internal.util.AtomicThrowable;
|
||||
import io.reactivex.internal.util.ErrorMode;
|
||||
import io.reactivex.plugins.RxJavaPlugins;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class ObservableConcatMapSingle<T, R> extends Observable<R> {
|
||||
final Observable<T> a;
|
||||
final Function<? super T, ? extends SingleSource<? extends R>> b;
|
||||
final ErrorMode c;
|
||||
final int d;
|
||||
|
||||
public ObservableConcatMapSingle(Observable<T> observable, Function<? super T, ? extends SingleSource<? extends R>> function, ErrorMode errorMode, int i) {
|
||||
this.a = observable;
|
||||
this.b = function;
|
||||
this.c = errorMode;
|
||||
this.d = i;
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observable
|
||||
protected void subscribeActual(Observer<? super R> observer) {
|
||||
if (ScalarXMapZHelper.b(this.a, this.b, observer)) {
|
||||
return;
|
||||
}
|
||||
this.a.subscribe(new ConcatMapSingleMainObserver(observer, this.b, this.d, this.c));
|
||||
}
|
||||
|
||||
static final class ConcatMapSingleMainObserver<T, R> extends AtomicInteger implements Observer<T>, Disposable {
|
||||
final Observer<? super R> a;
|
||||
final Function<? super T, ? extends SingleSource<? extends R>> b;
|
||||
final AtomicThrowable c = new AtomicThrowable();
|
||||
final ConcatMapSingleObserver<R> d = new ConcatMapSingleObserver<>(this);
|
||||
final SimplePlainQueue<T> e;
|
||||
final ErrorMode f;
|
||||
Disposable g;
|
||||
volatile boolean h;
|
||||
volatile boolean i;
|
||||
R j;
|
||||
volatile int k;
|
||||
|
||||
static final class ConcatMapSingleObserver<R> extends AtomicReference<Disposable> implements SingleObserver<R> {
|
||||
final ConcatMapSingleMainObserver<?, R> a;
|
||||
|
||||
ConcatMapSingleObserver(ConcatMapSingleMainObserver<?, R> concatMapSingleMainObserver) {
|
||||
this.a = concatMapSingleMainObserver;
|
||||
}
|
||||
|
||||
void a() {
|
||||
DisposableHelper.dispose(this);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.SingleObserver
|
||||
public void onError(Throwable th) {
|
||||
this.a.a(th);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.SingleObserver
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
DisposableHelper.replace(this, disposable);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.SingleObserver
|
||||
public void onSuccess(R r) {
|
||||
this.a.a((ConcatMapSingleMainObserver<?, R>) r);
|
||||
}
|
||||
}
|
||||
|
||||
ConcatMapSingleMainObserver(Observer<? super R> observer, Function<? super T, ? extends SingleSource<? extends R>> function, int i, ErrorMode errorMode) {
|
||||
this.a = observer;
|
||||
this.b = function;
|
||||
this.f = errorMode;
|
||||
this.e = new SpscLinkedArrayQueue(i);
|
||||
}
|
||||
|
||||
void a(R r) {
|
||||
this.j = r;
|
||||
this.k = 2;
|
||||
a();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.disposables.Disposable
|
||||
public void dispose() {
|
||||
this.i = true;
|
||||
this.g.dispose();
|
||||
this.d.a();
|
||||
if (getAndIncrement() == 0) {
|
||||
this.e.clear();
|
||||
this.j = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onComplete() {
|
||||
this.h = true;
|
||||
a();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onError(Throwable th) {
|
||||
if (!this.c.addThrowable(th)) {
|
||||
RxJavaPlugins.b(th);
|
||||
return;
|
||||
}
|
||||
if (this.f == ErrorMode.IMMEDIATE) {
|
||||
this.d.a();
|
||||
}
|
||||
this.h = true;
|
||||
a();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onNext(T t) {
|
||||
this.e.offer(t);
|
||||
a();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
if (DisposableHelper.validate(this.g, disposable)) {
|
||||
this.g = disposable;
|
||||
this.a.onSubscribe(this);
|
||||
}
|
||||
}
|
||||
|
||||
void a(Throwable th) {
|
||||
if (this.c.addThrowable(th)) {
|
||||
if (this.f != ErrorMode.END) {
|
||||
this.g.dispose();
|
||||
}
|
||||
this.k = 0;
|
||||
a();
|
||||
return;
|
||||
}
|
||||
RxJavaPlugins.b(th);
|
||||
}
|
||||
|
||||
void a() {
|
||||
if (getAndIncrement() != 0) {
|
||||
return;
|
||||
}
|
||||
Observer<? super R> observer = this.a;
|
||||
ErrorMode errorMode = this.f;
|
||||
SimplePlainQueue<T> simplePlainQueue = this.e;
|
||||
AtomicThrowable atomicThrowable = this.c;
|
||||
int i = 1;
|
||||
while (true) {
|
||||
if (this.i) {
|
||||
simplePlainQueue.clear();
|
||||
this.j = null;
|
||||
} else {
|
||||
int i2 = this.k;
|
||||
if (atomicThrowable.get() == null || (errorMode != ErrorMode.IMMEDIATE && (errorMode != ErrorMode.BOUNDARY || i2 != 0))) {
|
||||
if (i2 == 0) {
|
||||
boolean z = this.h;
|
||||
T poll = simplePlainQueue.poll();
|
||||
boolean z2 = poll == null;
|
||||
if (z && z2) {
|
||||
Throwable terminate = atomicThrowable.terminate();
|
||||
if (terminate == null) {
|
||||
observer.onComplete();
|
||||
return;
|
||||
} else {
|
||||
observer.onError(terminate);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!z2) {
|
||||
try {
|
||||
SingleSource<? extends R> apply = this.b.apply(poll);
|
||||
ObjectHelper.a(apply, "The mapper returned a null SingleSource");
|
||||
SingleSource<? extends R> singleSource = apply;
|
||||
this.k = 1;
|
||||
singleSource.a(this.d);
|
||||
} catch (Throwable th) {
|
||||
Exceptions.b(th);
|
||||
this.g.dispose();
|
||||
simplePlainQueue.clear();
|
||||
atomicThrowable.addThrowable(th);
|
||||
observer.onError(atomicThrowable.terminate());
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (i2 == 2) {
|
||||
R r = this.j;
|
||||
this.j = null;
|
||||
observer.onNext(r);
|
||||
this.k = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
i = addAndGet(-i);
|
||||
if (i == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
simplePlainQueue.clear();
|
||||
this.j = null;
|
||||
observer.onError(atomicThrowable.terminate());
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,189 @@
|
||||
package io.reactivex.internal.operators.mixed;
|
||||
|
||||
import io.reactivex.Completable;
|
||||
import io.reactivex.CompletableObserver;
|
||||
import io.reactivex.CompletableSource;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.exceptions.Exceptions;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.internal.disposables.DisposableHelper;
|
||||
import io.reactivex.internal.functions.ObjectHelper;
|
||||
import io.reactivex.internal.util.AtomicThrowable;
|
||||
import io.reactivex.internal.util.ExceptionHelper;
|
||||
import io.reactivex.plugins.RxJavaPlugins;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class ObservableSwitchMapCompletable<T> extends Completable {
|
||||
final Observable<T> a;
|
||||
final Function<? super T, ? extends CompletableSource> b;
|
||||
final boolean c;
|
||||
|
||||
public ObservableSwitchMapCompletable(Observable<T> observable, Function<? super T, ? extends CompletableSource> function, boolean z) {
|
||||
this.a = observable;
|
||||
this.b = function;
|
||||
this.c = z;
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Completable
|
||||
protected void b(CompletableObserver completableObserver) {
|
||||
if (ScalarXMapZHelper.a(this.a, this.b, completableObserver)) {
|
||||
return;
|
||||
}
|
||||
this.a.subscribe(new SwitchMapCompletableObserver(completableObserver, this.b, this.c));
|
||||
}
|
||||
|
||||
static final class SwitchMapCompletableObserver<T> implements Observer<T>, Disposable {
|
||||
static final SwitchMapInnerObserver h = new SwitchMapInnerObserver(null);
|
||||
final CompletableObserver a;
|
||||
final Function<? super T, ? extends CompletableSource> b;
|
||||
final boolean c;
|
||||
final AtomicThrowable d = new AtomicThrowable();
|
||||
final AtomicReference<SwitchMapInnerObserver> e = new AtomicReference<>();
|
||||
volatile boolean f;
|
||||
Disposable g;
|
||||
|
||||
static final class SwitchMapInnerObserver extends AtomicReference<Disposable> implements CompletableObserver {
|
||||
final SwitchMapCompletableObserver<?> a;
|
||||
|
||||
SwitchMapInnerObserver(SwitchMapCompletableObserver<?> switchMapCompletableObserver) {
|
||||
this.a = switchMapCompletableObserver;
|
||||
}
|
||||
|
||||
void a() {
|
||||
DisposableHelper.dispose(this);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.CompletableObserver, io.reactivex.MaybeObserver
|
||||
public void onComplete() {
|
||||
this.a.a(this);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.CompletableObserver
|
||||
public void onError(Throwable th) {
|
||||
this.a.a(this, th);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.CompletableObserver
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
DisposableHelper.setOnce(this, disposable);
|
||||
}
|
||||
}
|
||||
|
||||
SwitchMapCompletableObserver(CompletableObserver completableObserver, Function<? super T, ? extends CompletableSource> function, boolean z) {
|
||||
this.a = completableObserver;
|
||||
this.b = function;
|
||||
this.c = z;
|
||||
}
|
||||
|
||||
void a() {
|
||||
SwitchMapInnerObserver andSet = this.e.getAndSet(h);
|
||||
if (andSet == null || andSet == h) {
|
||||
return;
|
||||
}
|
||||
andSet.a();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.disposables.Disposable
|
||||
public void dispose() {
|
||||
this.g.dispose();
|
||||
a();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onComplete() {
|
||||
this.f = true;
|
||||
if (this.e.get() == null) {
|
||||
Throwable terminate = this.d.terminate();
|
||||
if (terminate == null) {
|
||||
this.a.onComplete();
|
||||
} else {
|
||||
this.a.onError(terminate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onError(Throwable th) {
|
||||
if (!this.d.addThrowable(th)) {
|
||||
RxJavaPlugins.b(th);
|
||||
return;
|
||||
}
|
||||
if (this.c) {
|
||||
onComplete();
|
||||
return;
|
||||
}
|
||||
a();
|
||||
Throwable terminate = this.d.terminate();
|
||||
if (terminate != ExceptionHelper.a) {
|
||||
this.a.onError(terminate);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onNext(T t) {
|
||||
SwitchMapInnerObserver switchMapInnerObserver;
|
||||
try {
|
||||
CompletableSource apply = this.b.apply(t);
|
||||
ObjectHelper.a(apply, "The mapper returned a null CompletableSource");
|
||||
CompletableSource completableSource = apply;
|
||||
SwitchMapInnerObserver switchMapInnerObserver2 = new SwitchMapInnerObserver(this);
|
||||
do {
|
||||
switchMapInnerObserver = this.e.get();
|
||||
if (switchMapInnerObserver == h) {
|
||||
return;
|
||||
}
|
||||
} while (!this.e.compareAndSet(switchMapInnerObserver, switchMapInnerObserver2));
|
||||
if (switchMapInnerObserver != null) {
|
||||
switchMapInnerObserver.a();
|
||||
}
|
||||
completableSource.a(switchMapInnerObserver2);
|
||||
} catch (Throwable th) {
|
||||
Exceptions.b(th);
|
||||
this.g.dispose();
|
||||
onError(th);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
if (DisposableHelper.validate(this.g, disposable)) {
|
||||
this.g = disposable;
|
||||
this.a.onSubscribe(this);
|
||||
}
|
||||
}
|
||||
|
||||
void a(SwitchMapInnerObserver switchMapInnerObserver, Throwable th) {
|
||||
if (this.e.compareAndSet(switchMapInnerObserver, null) && this.d.addThrowable(th)) {
|
||||
if (this.c) {
|
||||
if (this.f) {
|
||||
this.a.onError(this.d.terminate());
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
dispose();
|
||||
Throwable terminate = this.d.terminate();
|
||||
if (terminate != ExceptionHelper.a) {
|
||||
this.a.onError(terminate);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
RxJavaPlugins.b(th);
|
||||
}
|
||||
|
||||
void a(SwitchMapInnerObserver switchMapInnerObserver) {
|
||||
if (this.e.compareAndSet(switchMapInnerObserver, null) && this.f) {
|
||||
Throwable terminate = this.d.terminate();
|
||||
if (terminate == null) {
|
||||
this.a.onComplete();
|
||||
} else {
|
||||
this.a.onError(terminate);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,213 @@
|
||||
package io.reactivex.internal.operators.mixed;
|
||||
|
||||
import io.reactivex.MaybeObserver;
|
||||
import io.reactivex.MaybeSource;
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.exceptions.Exceptions;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.internal.disposables.DisposableHelper;
|
||||
import io.reactivex.internal.functions.ObjectHelper;
|
||||
import io.reactivex.internal.util.AtomicThrowable;
|
||||
import io.reactivex.plugins.RxJavaPlugins;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class ObservableSwitchMapMaybe<T, R> extends Observable<R> {
|
||||
final Observable<T> a;
|
||||
final Function<? super T, ? extends MaybeSource<? extends R>> b;
|
||||
final boolean c;
|
||||
|
||||
public ObservableSwitchMapMaybe(Observable<T> observable, Function<? super T, ? extends MaybeSource<? extends R>> function, boolean z) {
|
||||
this.a = observable;
|
||||
this.b = function;
|
||||
this.c = z;
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observable
|
||||
protected void subscribeActual(Observer<? super R> observer) {
|
||||
if (ScalarXMapZHelper.a(this.a, this.b, observer)) {
|
||||
return;
|
||||
}
|
||||
this.a.subscribe(new SwitchMapMaybeMainObserver(observer, this.b, this.c));
|
||||
}
|
||||
|
||||
static final class SwitchMapMaybeMainObserver<T, R> extends AtomicInteger implements Observer<T>, Disposable {
|
||||
static final SwitchMapMaybeObserver<Object> i = new SwitchMapMaybeObserver<>(null);
|
||||
final Observer<? super R> a;
|
||||
final Function<? super T, ? extends MaybeSource<? extends R>> b;
|
||||
final boolean c;
|
||||
final AtomicThrowable d = new AtomicThrowable();
|
||||
final AtomicReference<SwitchMapMaybeObserver<R>> e = new AtomicReference<>();
|
||||
Disposable f;
|
||||
volatile boolean g;
|
||||
volatile boolean h;
|
||||
|
||||
static final class SwitchMapMaybeObserver<R> extends AtomicReference<Disposable> implements MaybeObserver<R> {
|
||||
final SwitchMapMaybeMainObserver<?, R> a;
|
||||
volatile R b;
|
||||
|
||||
SwitchMapMaybeObserver(SwitchMapMaybeMainObserver<?, R> switchMapMaybeMainObserver) {
|
||||
this.a = switchMapMaybeMainObserver;
|
||||
}
|
||||
|
||||
void a() {
|
||||
DisposableHelper.dispose(this);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.MaybeObserver
|
||||
public void onComplete() {
|
||||
this.a.a(this);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.MaybeObserver
|
||||
public void onError(Throwable th) {
|
||||
this.a.a(this, th);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.MaybeObserver
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
DisposableHelper.setOnce(this, disposable);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.MaybeObserver
|
||||
public void onSuccess(R r) {
|
||||
this.b = r;
|
||||
this.a.b();
|
||||
}
|
||||
}
|
||||
|
||||
SwitchMapMaybeMainObserver(Observer<? super R> observer, Function<? super T, ? extends MaybeSource<? extends R>> function, boolean z) {
|
||||
this.a = observer;
|
||||
this.b = function;
|
||||
this.c = z;
|
||||
}
|
||||
|
||||
void a() {
|
||||
SwitchMapMaybeObserver<Object> switchMapMaybeObserver = (SwitchMapMaybeObserver) this.e.getAndSet(i);
|
||||
if (switchMapMaybeObserver == null || switchMapMaybeObserver == i) {
|
||||
return;
|
||||
}
|
||||
switchMapMaybeObserver.a();
|
||||
}
|
||||
|
||||
void b() {
|
||||
if (getAndIncrement() != 0) {
|
||||
return;
|
||||
}
|
||||
Observer<? super R> observer = this.a;
|
||||
AtomicThrowable atomicThrowable = this.d;
|
||||
AtomicReference<SwitchMapMaybeObserver<R>> atomicReference = this.e;
|
||||
int i2 = 1;
|
||||
while (!this.h) {
|
||||
if (atomicThrowable.get() != null && !this.c) {
|
||||
observer.onError(atomicThrowable.terminate());
|
||||
return;
|
||||
}
|
||||
boolean z = this.g;
|
||||
SwitchMapMaybeObserver<R> switchMapMaybeObserver = atomicReference.get();
|
||||
boolean z2 = switchMapMaybeObserver == null;
|
||||
if (z && z2) {
|
||||
Throwable terminate = atomicThrowable.terminate();
|
||||
if (terminate != null) {
|
||||
observer.onError(terminate);
|
||||
return;
|
||||
} else {
|
||||
observer.onComplete();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (z2 || switchMapMaybeObserver.b == null) {
|
||||
i2 = addAndGet(-i2);
|
||||
if (i2 == 0) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
atomicReference.compareAndSet(switchMapMaybeObserver, null);
|
||||
observer.onNext(switchMapMaybeObserver.b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.disposables.Disposable
|
||||
public void dispose() {
|
||||
this.h = true;
|
||||
this.f.dispose();
|
||||
a();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onComplete() {
|
||||
this.g = true;
|
||||
b();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onError(Throwable th) {
|
||||
if (!this.d.addThrowable(th)) {
|
||||
RxJavaPlugins.b(th);
|
||||
return;
|
||||
}
|
||||
if (!this.c) {
|
||||
a();
|
||||
}
|
||||
this.g = true;
|
||||
b();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onNext(T t) {
|
||||
SwitchMapMaybeObserver<R> switchMapMaybeObserver;
|
||||
SwitchMapMaybeObserver<R> switchMapMaybeObserver2 = this.e.get();
|
||||
if (switchMapMaybeObserver2 != null) {
|
||||
switchMapMaybeObserver2.a();
|
||||
}
|
||||
try {
|
||||
MaybeSource<? extends R> apply = this.b.apply(t);
|
||||
ObjectHelper.a(apply, "The mapper returned a null MaybeSource");
|
||||
MaybeSource<? extends R> maybeSource = apply;
|
||||
SwitchMapMaybeObserver<R> switchMapMaybeObserver3 = new SwitchMapMaybeObserver<>(this);
|
||||
do {
|
||||
switchMapMaybeObserver = this.e.get();
|
||||
if (switchMapMaybeObserver == i) {
|
||||
return;
|
||||
}
|
||||
} while (!this.e.compareAndSet(switchMapMaybeObserver, switchMapMaybeObserver3));
|
||||
maybeSource.a(switchMapMaybeObserver3);
|
||||
} catch (Throwable th) {
|
||||
Exceptions.b(th);
|
||||
this.f.dispose();
|
||||
this.e.getAndSet(i);
|
||||
onError(th);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
if (DisposableHelper.validate(this.f, disposable)) {
|
||||
this.f = disposable;
|
||||
this.a.onSubscribe(this);
|
||||
}
|
||||
}
|
||||
|
||||
void a(SwitchMapMaybeObserver<R> switchMapMaybeObserver, Throwable th) {
|
||||
if (this.e.compareAndSet(switchMapMaybeObserver, null) && this.d.addThrowable(th)) {
|
||||
if (!this.c) {
|
||||
this.f.dispose();
|
||||
a();
|
||||
}
|
||||
b();
|
||||
return;
|
||||
}
|
||||
RxJavaPlugins.b(th);
|
||||
}
|
||||
|
||||
void a(SwitchMapMaybeObserver<R> switchMapMaybeObserver) {
|
||||
if (this.e.compareAndSet(switchMapMaybeObserver, null)) {
|
||||
b();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,202 @@
|
||||
package io.reactivex.internal.operators.mixed;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.SingleSource;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.exceptions.Exceptions;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.internal.disposables.DisposableHelper;
|
||||
import io.reactivex.internal.functions.ObjectHelper;
|
||||
import io.reactivex.internal.util.AtomicThrowable;
|
||||
import io.reactivex.plugins.RxJavaPlugins;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class ObservableSwitchMapSingle<T, R> extends Observable<R> {
|
||||
final Observable<T> a;
|
||||
final Function<? super T, ? extends SingleSource<? extends R>> b;
|
||||
final boolean c;
|
||||
|
||||
public ObservableSwitchMapSingle(Observable<T> observable, Function<? super T, ? extends SingleSource<? extends R>> function, boolean z) {
|
||||
this.a = observable;
|
||||
this.b = function;
|
||||
this.c = z;
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observable
|
||||
protected void subscribeActual(Observer<? super R> observer) {
|
||||
if (ScalarXMapZHelper.b(this.a, this.b, observer)) {
|
||||
return;
|
||||
}
|
||||
this.a.subscribe(new SwitchMapSingleMainObserver(observer, this.b, this.c));
|
||||
}
|
||||
|
||||
static final class SwitchMapSingleMainObserver<T, R> extends AtomicInteger implements Observer<T>, Disposable {
|
||||
static final SwitchMapSingleObserver<Object> i = new SwitchMapSingleObserver<>(null);
|
||||
final Observer<? super R> a;
|
||||
final Function<? super T, ? extends SingleSource<? extends R>> b;
|
||||
final boolean c;
|
||||
final AtomicThrowable d = new AtomicThrowable();
|
||||
final AtomicReference<SwitchMapSingleObserver<R>> e = new AtomicReference<>();
|
||||
Disposable f;
|
||||
volatile boolean g;
|
||||
volatile boolean h;
|
||||
|
||||
static final class SwitchMapSingleObserver<R> extends AtomicReference<Disposable> implements SingleObserver<R> {
|
||||
final SwitchMapSingleMainObserver<?, R> a;
|
||||
volatile R b;
|
||||
|
||||
SwitchMapSingleObserver(SwitchMapSingleMainObserver<?, R> switchMapSingleMainObserver) {
|
||||
this.a = switchMapSingleMainObserver;
|
||||
}
|
||||
|
||||
void a() {
|
||||
DisposableHelper.dispose(this);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.SingleObserver
|
||||
public void onError(Throwable th) {
|
||||
this.a.a(this, th);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.SingleObserver
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
DisposableHelper.setOnce(this, disposable);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.SingleObserver
|
||||
public void onSuccess(R r) {
|
||||
this.b = r;
|
||||
this.a.b();
|
||||
}
|
||||
}
|
||||
|
||||
SwitchMapSingleMainObserver(Observer<? super R> observer, Function<? super T, ? extends SingleSource<? extends R>> function, boolean z) {
|
||||
this.a = observer;
|
||||
this.b = function;
|
||||
this.c = z;
|
||||
}
|
||||
|
||||
void a() {
|
||||
SwitchMapSingleObserver<Object> switchMapSingleObserver = (SwitchMapSingleObserver) this.e.getAndSet(i);
|
||||
if (switchMapSingleObserver == null || switchMapSingleObserver == i) {
|
||||
return;
|
||||
}
|
||||
switchMapSingleObserver.a();
|
||||
}
|
||||
|
||||
void b() {
|
||||
if (getAndIncrement() != 0) {
|
||||
return;
|
||||
}
|
||||
Observer<? super R> observer = this.a;
|
||||
AtomicThrowable atomicThrowable = this.d;
|
||||
AtomicReference<SwitchMapSingleObserver<R>> atomicReference = this.e;
|
||||
int i2 = 1;
|
||||
while (!this.h) {
|
||||
if (atomicThrowable.get() != null && !this.c) {
|
||||
observer.onError(atomicThrowable.terminate());
|
||||
return;
|
||||
}
|
||||
boolean z = this.g;
|
||||
SwitchMapSingleObserver<R> switchMapSingleObserver = atomicReference.get();
|
||||
boolean z2 = switchMapSingleObserver == null;
|
||||
if (z && z2) {
|
||||
Throwable terminate = atomicThrowable.terminate();
|
||||
if (terminate != null) {
|
||||
observer.onError(terminate);
|
||||
return;
|
||||
} else {
|
||||
observer.onComplete();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (z2 || switchMapSingleObserver.b == null) {
|
||||
i2 = addAndGet(-i2);
|
||||
if (i2 == 0) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
atomicReference.compareAndSet(switchMapSingleObserver, null);
|
||||
observer.onNext(switchMapSingleObserver.b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.disposables.Disposable
|
||||
public void dispose() {
|
||||
this.h = true;
|
||||
this.f.dispose();
|
||||
a();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onComplete() {
|
||||
this.g = true;
|
||||
b();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onError(Throwable th) {
|
||||
if (!this.d.addThrowable(th)) {
|
||||
RxJavaPlugins.b(th);
|
||||
return;
|
||||
}
|
||||
if (!this.c) {
|
||||
a();
|
||||
}
|
||||
this.g = true;
|
||||
b();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onNext(T t) {
|
||||
SwitchMapSingleObserver<R> switchMapSingleObserver;
|
||||
SwitchMapSingleObserver<R> switchMapSingleObserver2 = this.e.get();
|
||||
if (switchMapSingleObserver2 != null) {
|
||||
switchMapSingleObserver2.a();
|
||||
}
|
||||
try {
|
||||
SingleSource<? extends R> apply = this.b.apply(t);
|
||||
ObjectHelper.a(apply, "The mapper returned a null SingleSource");
|
||||
SingleSource<? extends R> singleSource = apply;
|
||||
SwitchMapSingleObserver<R> switchMapSingleObserver3 = new SwitchMapSingleObserver<>(this);
|
||||
do {
|
||||
switchMapSingleObserver = this.e.get();
|
||||
if (switchMapSingleObserver == i) {
|
||||
return;
|
||||
}
|
||||
} while (!this.e.compareAndSet(switchMapSingleObserver, switchMapSingleObserver3));
|
||||
singleSource.a(switchMapSingleObserver3);
|
||||
} catch (Throwable th) {
|
||||
Exceptions.b(th);
|
||||
this.f.dispose();
|
||||
this.e.getAndSet(i);
|
||||
onError(th);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
if (DisposableHelper.validate(this.f, disposable)) {
|
||||
this.f = disposable;
|
||||
this.a.onSubscribe(this);
|
||||
}
|
||||
}
|
||||
|
||||
void a(SwitchMapSingleObserver<R> switchMapSingleObserver, Throwable th) {
|
||||
if (this.e.compareAndSet(switchMapSingleObserver, null) && this.d.addThrowable(th)) {
|
||||
if (!this.c) {
|
||||
this.f.dispose();
|
||||
a();
|
||||
}
|
||||
b();
|
||||
return;
|
||||
}
|
||||
RxJavaPlugins.b(th);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,93 @@
|
||||
package io.reactivex.internal.operators.mixed;
|
||||
|
||||
import android.Manifest;
|
||||
import io.reactivex.CompletableObserver;
|
||||
import io.reactivex.CompletableSource;
|
||||
import io.reactivex.MaybeSource;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.SingleSource;
|
||||
import io.reactivex.exceptions.Exceptions;
|
||||
import io.reactivex.functions.Function;
|
||||
import io.reactivex.internal.disposables.EmptyDisposable;
|
||||
import io.reactivex.internal.functions.ObjectHelper;
|
||||
import io.reactivex.internal.operators.maybe.MaybeToObservable;
|
||||
import io.reactivex.internal.operators.single.SingleToObservable;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
final class ScalarXMapZHelper {
|
||||
static <T> boolean a(Object obj, Function<? super T, ? extends CompletableSource> function, CompletableObserver completableObserver) {
|
||||
if (!(obj instanceof Callable)) {
|
||||
return false;
|
||||
}
|
||||
CompletableSource completableSource = null;
|
||||
try {
|
||||
Manifest manifest = (Object) ((Callable) obj).call();
|
||||
if (manifest != null) {
|
||||
CompletableSource apply = function.apply(manifest);
|
||||
ObjectHelper.a(apply, "The mapper returned a null CompletableSource");
|
||||
completableSource = apply;
|
||||
}
|
||||
if (completableSource == null) {
|
||||
EmptyDisposable.complete(completableObserver);
|
||||
} else {
|
||||
completableSource.a(completableObserver);
|
||||
}
|
||||
return true;
|
||||
} catch (Throwable th) {
|
||||
Exceptions.b(th);
|
||||
EmptyDisposable.error(th, completableObserver);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static <T, R> boolean b(Object obj, Function<? super T, ? extends SingleSource<? extends R>> function, Observer<? super R> observer) {
|
||||
if (!(obj instanceof Callable)) {
|
||||
return false;
|
||||
}
|
||||
SingleSource<? extends R> singleSource = null;
|
||||
try {
|
||||
Manifest manifest = (Object) ((Callable) obj).call();
|
||||
if (manifest != null) {
|
||||
SingleSource<? extends R> apply = function.apply(manifest);
|
||||
ObjectHelper.a(apply, "The mapper returned a null SingleSource");
|
||||
singleSource = apply;
|
||||
}
|
||||
if (singleSource == null) {
|
||||
EmptyDisposable.complete(observer);
|
||||
} else {
|
||||
singleSource.a(SingleToObservable.a(observer));
|
||||
}
|
||||
return true;
|
||||
} catch (Throwable th) {
|
||||
Exceptions.b(th);
|
||||
EmptyDisposable.error(th, observer);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static <T, R> boolean a(Object obj, Function<? super T, ? extends MaybeSource<? extends R>> function, Observer<? super R> observer) {
|
||||
if (!(obj instanceof Callable)) {
|
||||
return false;
|
||||
}
|
||||
MaybeSource<? extends R> maybeSource = null;
|
||||
try {
|
||||
Manifest manifest = (Object) ((Callable) obj).call();
|
||||
if (manifest != null) {
|
||||
MaybeSource<? extends R> apply = function.apply(manifest);
|
||||
ObjectHelper.a(apply, "The mapper returned a null MaybeSource");
|
||||
maybeSource = apply;
|
||||
}
|
||||
if (maybeSource == null) {
|
||||
EmptyDisposable.complete(observer);
|
||||
} else {
|
||||
maybeSource.a(MaybeToObservable.a(observer));
|
||||
}
|
||||
return true;
|
||||
} catch (Throwable th) {
|
||||
Exceptions.b(th);
|
||||
EmptyDisposable.error(th, observer);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user