Initial commit
This commit is contained in:
67
sources/io/reactivex/observers/BaseTestConsumer.java
Normal file
67
sources/io/reactivex/observers/BaseTestConsumer.java
Normal file
@@ -0,0 +1,67 @@
|
||||
package io.reactivex.observers;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.internal.util.VolatileSizeArrayList;
|
||||
import io.reactivex.observers.BaseTestConsumer;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public abstract class BaseTestConsumer<T, U extends BaseTestConsumer<T, U>> implements Disposable {
|
||||
protected long d;
|
||||
protected boolean e;
|
||||
protected int f;
|
||||
protected int g;
|
||||
protected final List<T> b = new VolatileSizeArrayList();
|
||||
protected final List<Throwable> c = new VolatileSizeArrayList();
|
||||
protected final CountDownLatch a = new CountDownLatch(1);
|
||||
|
||||
public enum TestWaitStrategy implements Runnable {
|
||||
SPIN { // from class: io.reactivex.observers.BaseTestConsumer.TestWaitStrategy.1
|
||||
@Override // io.reactivex.observers.BaseTestConsumer.TestWaitStrategy, java.lang.Runnable
|
||||
public void run() {
|
||||
}
|
||||
},
|
||||
YIELD { // from class: io.reactivex.observers.BaseTestConsumer.TestWaitStrategy.2
|
||||
@Override // io.reactivex.observers.BaseTestConsumer.TestWaitStrategy, java.lang.Runnable
|
||||
public void run() {
|
||||
Thread.yield();
|
||||
}
|
||||
},
|
||||
SLEEP_1MS { // from class: io.reactivex.observers.BaseTestConsumer.TestWaitStrategy.3
|
||||
@Override // io.reactivex.observers.BaseTestConsumer.TestWaitStrategy, java.lang.Runnable
|
||||
public void run() {
|
||||
TestWaitStrategy.sleep(1);
|
||||
}
|
||||
},
|
||||
SLEEP_10MS { // from class: io.reactivex.observers.BaseTestConsumer.TestWaitStrategy.4
|
||||
@Override // io.reactivex.observers.BaseTestConsumer.TestWaitStrategy, java.lang.Runnable
|
||||
public void run() {
|
||||
TestWaitStrategy.sleep(10);
|
||||
}
|
||||
},
|
||||
SLEEP_100MS { // from class: io.reactivex.observers.BaseTestConsumer.TestWaitStrategy.5
|
||||
@Override // io.reactivex.observers.BaseTestConsumer.TestWaitStrategy, java.lang.Runnable
|
||||
public void run() {
|
||||
TestWaitStrategy.sleep(100);
|
||||
}
|
||||
},
|
||||
SLEEP_1000MS { // from class: io.reactivex.observers.BaseTestConsumer.TestWaitStrategy.6
|
||||
@Override // io.reactivex.observers.BaseTestConsumer.TestWaitStrategy, java.lang.Runnable
|
||||
public void run() {
|
||||
TestWaitStrategy.sleep(1000);
|
||||
}
|
||||
};
|
||||
|
||||
static void sleep(int i) {
|
||||
try {
|
||||
Thread.sleep(i);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public abstract void run();
|
||||
}
|
||||
}
|
21
sources/io/reactivex/observers/DefaultObserver.java
Normal file
21
sources/io/reactivex/observers/DefaultObserver.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package io.reactivex.observers;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.internal.util.EndConsumerHelper;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public abstract class DefaultObserver<T> implements Observer<T> {
|
||||
private Disposable a;
|
||||
|
||||
protected void a() {
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public final void onSubscribe(Disposable disposable) {
|
||||
if (EndConsumerHelper.a(this.a, disposable, getClass())) {
|
||||
this.a = disposable;
|
||||
a();
|
||||
}
|
||||
}
|
||||
}
|
27
sources/io/reactivex/observers/DisposableObserver.java
Normal file
27
sources/io/reactivex/observers/DisposableObserver.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package io.reactivex.observers;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.internal.disposables.DisposableHelper;
|
||||
import io.reactivex.internal.util.EndConsumerHelper;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public abstract class DisposableObserver<T> implements Observer<T>, Disposable {
|
||||
final AtomicReference<Disposable> a = new AtomicReference<>();
|
||||
|
||||
protected void a() {
|
||||
}
|
||||
|
||||
@Override // io.reactivex.disposables.Disposable
|
||||
public final void dispose() {
|
||||
DisposableHelper.dispose(this.a);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public final void onSubscribe(Disposable disposable) {
|
||||
if (EndConsumerHelper.a(this.a, disposable, getClass())) {
|
||||
a();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
package io.reactivex.observers;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface LambdaConsumerIntrospection {
|
||||
}
|
166
sources/io/reactivex/observers/SafeObserver.java
Normal file
166
sources/io/reactivex/observers/SafeObserver.java
Normal file
@@ -0,0 +1,166 @@
|
||||
package io.reactivex.observers;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.exceptions.CompositeException;
|
||||
import io.reactivex.exceptions.Exceptions;
|
||||
import io.reactivex.internal.disposables.DisposableHelper;
|
||||
import io.reactivex.internal.disposables.EmptyDisposable;
|
||||
import io.reactivex.plugins.RxJavaPlugins;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class SafeObserver<T> implements Observer<T>, Disposable {
|
||||
final Observer<? super T> a;
|
||||
Disposable b;
|
||||
boolean c;
|
||||
|
||||
public SafeObserver(Observer<? super T> observer) {
|
||||
this.a = observer;
|
||||
}
|
||||
|
||||
void a() {
|
||||
NullPointerException nullPointerException = new NullPointerException("Subscription not set!");
|
||||
try {
|
||||
this.a.onSubscribe(EmptyDisposable.INSTANCE);
|
||||
try {
|
||||
this.a.onError(nullPointerException);
|
||||
} catch (Throwable th) {
|
||||
Exceptions.b(th);
|
||||
RxJavaPlugins.b(new CompositeException(nullPointerException, th));
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
Exceptions.b(th2);
|
||||
RxJavaPlugins.b(new CompositeException(nullPointerException, th2));
|
||||
}
|
||||
}
|
||||
|
||||
void b() {
|
||||
this.c = true;
|
||||
NullPointerException nullPointerException = new NullPointerException("Subscription not set!");
|
||||
try {
|
||||
this.a.onSubscribe(EmptyDisposable.INSTANCE);
|
||||
try {
|
||||
this.a.onError(nullPointerException);
|
||||
} catch (Throwable th) {
|
||||
Exceptions.b(th);
|
||||
RxJavaPlugins.b(new CompositeException(nullPointerException, th));
|
||||
}
|
||||
} catch (Throwable th2) {
|
||||
Exceptions.b(th2);
|
||||
RxJavaPlugins.b(new CompositeException(nullPointerException, th2));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.disposables.Disposable
|
||||
public void dispose() {
|
||||
this.b.dispose();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onComplete() {
|
||||
if (this.c) {
|
||||
return;
|
||||
}
|
||||
this.c = true;
|
||||
if (this.b == null) {
|
||||
a();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.a.onComplete();
|
||||
} catch (Throwable th) {
|
||||
Exceptions.b(th);
|
||||
RxJavaPlugins.b(th);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onError(Throwable th) {
|
||||
if (this.c) {
|
||||
RxJavaPlugins.b(th);
|
||||
return;
|
||||
}
|
||||
this.c = true;
|
||||
if (this.b != null) {
|
||||
if (th == null) {
|
||||
th = new NullPointerException("onError called with null. Null values are generally not allowed in 2.x operators and sources.");
|
||||
}
|
||||
try {
|
||||
this.a.onError(th);
|
||||
return;
|
||||
} catch (Throwable th2) {
|
||||
Exceptions.b(th2);
|
||||
RxJavaPlugins.b(new CompositeException(th, th2));
|
||||
return;
|
||||
}
|
||||
}
|
||||
NullPointerException nullPointerException = new NullPointerException("Subscription not set!");
|
||||
try {
|
||||
this.a.onSubscribe(EmptyDisposable.INSTANCE);
|
||||
try {
|
||||
this.a.onError(new CompositeException(th, nullPointerException));
|
||||
} catch (Throwable th3) {
|
||||
Exceptions.b(th3);
|
||||
RxJavaPlugins.b(new CompositeException(th, nullPointerException, th3));
|
||||
}
|
||||
} catch (Throwable th4) {
|
||||
Exceptions.b(th4);
|
||||
RxJavaPlugins.b(new CompositeException(th, nullPointerException, th4));
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onNext(T t) {
|
||||
if (this.c) {
|
||||
return;
|
||||
}
|
||||
if (this.b == null) {
|
||||
b();
|
||||
return;
|
||||
}
|
||||
if (t == null) {
|
||||
NullPointerException nullPointerException = new NullPointerException("onNext called with null. Null values are generally not allowed in 2.x operators and sources.");
|
||||
try {
|
||||
this.b.dispose();
|
||||
onError(nullPointerException);
|
||||
return;
|
||||
} catch (Throwable th) {
|
||||
Exceptions.b(th);
|
||||
onError(new CompositeException(nullPointerException, th));
|
||||
return;
|
||||
}
|
||||
}
|
||||
try {
|
||||
this.a.onNext(t);
|
||||
} catch (Throwable th2) {
|
||||
Exceptions.b(th2);
|
||||
try {
|
||||
this.b.dispose();
|
||||
onError(th2);
|
||||
} catch (Throwable th3) {
|
||||
Exceptions.b(th3);
|
||||
onError(new CompositeException(th2, th3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
if (DisposableHelper.validate(this.b, disposable)) {
|
||||
this.b = disposable;
|
||||
try {
|
||||
this.a.onSubscribe(this);
|
||||
} catch (Throwable th) {
|
||||
Exceptions.b(th);
|
||||
this.c = true;
|
||||
try {
|
||||
disposable.dispose();
|
||||
RxJavaPlugins.b(th);
|
||||
} catch (Throwable th2) {
|
||||
Exceptions.b(th2);
|
||||
RxJavaPlugins.b(new CompositeException(th, th2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
143
sources/io/reactivex/observers/SerializedObserver.java
Normal file
143
sources/io/reactivex/observers/SerializedObserver.java
Normal file
@@ -0,0 +1,143 @@
|
||||
package io.reactivex.observers;
|
||||
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.internal.disposables.DisposableHelper;
|
||||
import io.reactivex.internal.util.AppendOnlyLinkedArrayList;
|
||||
import io.reactivex.internal.util.NotificationLite;
|
||||
import io.reactivex.plugins.RxJavaPlugins;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class SerializedObserver<T> implements Observer<T>, Disposable {
|
||||
final Observer<? super T> a;
|
||||
final boolean b;
|
||||
Disposable c;
|
||||
boolean d;
|
||||
AppendOnlyLinkedArrayList<Object> e;
|
||||
volatile boolean f;
|
||||
|
||||
public SerializedObserver(Observer<? super T> observer) {
|
||||
this(observer, false);
|
||||
}
|
||||
|
||||
void a() {
|
||||
AppendOnlyLinkedArrayList<Object> appendOnlyLinkedArrayList;
|
||||
do {
|
||||
synchronized (this) {
|
||||
appendOnlyLinkedArrayList = this.e;
|
||||
if (appendOnlyLinkedArrayList == null) {
|
||||
this.d = false;
|
||||
return;
|
||||
}
|
||||
this.e = null;
|
||||
}
|
||||
} while (!appendOnlyLinkedArrayList.a((Observer) this.a));
|
||||
}
|
||||
|
||||
@Override // io.reactivex.disposables.Disposable
|
||||
public void dispose() {
|
||||
this.c.dispose();
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onComplete() {
|
||||
if (this.f) {
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (this.f) {
|
||||
return;
|
||||
}
|
||||
if (!this.d) {
|
||||
this.f = true;
|
||||
this.d = true;
|
||||
this.a.onComplete();
|
||||
} else {
|
||||
AppendOnlyLinkedArrayList<Object> appendOnlyLinkedArrayList = this.e;
|
||||
if (appendOnlyLinkedArrayList == null) {
|
||||
appendOnlyLinkedArrayList = new AppendOnlyLinkedArrayList<>(4);
|
||||
this.e = appendOnlyLinkedArrayList;
|
||||
}
|
||||
appendOnlyLinkedArrayList.a((AppendOnlyLinkedArrayList<Object>) NotificationLite.complete());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onError(Throwable th) {
|
||||
if (this.f) {
|
||||
RxJavaPlugins.b(th);
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
boolean z = true;
|
||||
if (!this.f) {
|
||||
if (this.d) {
|
||||
this.f = true;
|
||||
AppendOnlyLinkedArrayList<Object> appendOnlyLinkedArrayList = this.e;
|
||||
if (appendOnlyLinkedArrayList == null) {
|
||||
appendOnlyLinkedArrayList = new AppendOnlyLinkedArrayList<>(4);
|
||||
this.e = appendOnlyLinkedArrayList;
|
||||
}
|
||||
Object error = NotificationLite.error(th);
|
||||
if (this.b) {
|
||||
appendOnlyLinkedArrayList.a((AppendOnlyLinkedArrayList<Object>) error);
|
||||
} else {
|
||||
appendOnlyLinkedArrayList.b(error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.f = true;
|
||||
this.d = true;
|
||||
z = false;
|
||||
}
|
||||
if (z) {
|
||||
RxJavaPlugins.b(th);
|
||||
} else {
|
||||
this.a.onError(th);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onNext(T t) {
|
||||
if (this.f) {
|
||||
return;
|
||||
}
|
||||
if (t == null) {
|
||||
this.c.dispose();
|
||||
onError(new NullPointerException("onNext called with null. Null values are generally not allowed in 2.x operators and sources."));
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (this.f) {
|
||||
return;
|
||||
}
|
||||
if (!this.d) {
|
||||
this.d = true;
|
||||
this.a.onNext(t);
|
||||
a();
|
||||
} else {
|
||||
AppendOnlyLinkedArrayList<Object> appendOnlyLinkedArrayList = this.e;
|
||||
if (appendOnlyLinkedArrayList == null) {
|
||||
appendOnlyLinkedArrayList = new AppendOnlyLinkedArrayList<>(4);
|
||||
this.e = appendOnlyLinkedArrayList;
|
||||
}
|
||||
appendOnlyLinkedArrayList.a((AppendOnlyLinkedArrayList<Object>) NotificationLite.next(t));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
if (DisposableHelper.validate(this.c, disposable)) {
|
||||
this.c = disposable;
|
||||
this.a.onSubscribe(this);
|
||||
}
|
||||
}
|
||||
|
||||
public SerializedObserver(Observer<? super T> observer, boolean z) {
|
||||
this.a = observer;
|
||||
this.b = z;
|
||||
}
|
||||
}
|
170
sources/io/reactivex/observers/TestObserver.java
Normal file
170
sources/io/reactivex/observers/TestObserver.java
Normal file
@@ -0,0 +1,170 @@
|
||||
package io.reactivex.observers;
|
||||
|
||||
import io.reactivex.CompletableObserver;
|
||||
import io.reactivex.MaybeObserver;
|
||||
import io.reactivex.Observer;
|
||||
import io.reactivex.SingleObserver;
|
||||
import io.reactivex.disposables.Disposable;
|
||||
import io.reactivex.internal.disposables.DisposableHelper;
|
||||
import io.reactivex.internal.fuseable.QueueDisposable;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public class TestObserver<T> extends BaseTestConsumer<T, TestObserver<T>> implements Observer<T>, Disposable, MaybeObserver<T>, SingleObserver<T>, CompletableObserver {
|
||||
private final Observer<? super T> h;
|
||||
private final AtomicReference<Disposable> i;
|
||||
private QueueDisposable<T> j;
|
||||
|
||||
enum EmptyObserver implements Observer<Object> {
|
||||
INSTANCE;
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onComplete() {
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onError(Throwable th) {
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onNext(Object obj) {
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
}
|
||||
}
|
||||
|
||||
public TestObserver() {
|
||||
this(EmptyObserver.INSTANCE);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.disposables.Disposable
|
||||
public final void dispose() {
|
||||
DisposableHelper.dispose(this.i);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onComplete() {
|
||||
if (!this.e) {
|
||||
this.e = true;
|
||||
if (this.i.get() == null) {
|
||||
this.c.add(new IllegalStateException("onSubscribe not called in proper order"));
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.currentThread();
|
||||
this.d++;
|
||||
this.h.onComplete();
|
||||
} finally {
|
||||
this.a.countDown();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onError(Throwable th) {
|
||||
if (!this.e) {
|
||||
this.e = true;
|
||||
if (this.i.get() == null) {
|
||||
this.c.add(new IllegalStateException("onSubscribe not called in proper order"));
|
||||
}
|
||||
}
|
||||
try {
|
||||
Thread.currentThread();
|
||||
if (th == null) {
|
||||
this.c.add(new NullPointerException("onError received a null Throwable"));
|
||||
} else {
|
||||
this.c.add(th);
|
||||
}
|
||||
this.h.onError(th);
|
||||
} finally {
|
||||
this.a.countDown();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onNext(T t) {
|
||||
if (!this.e) {
|
||||
this.e = true;
|
||||
if (this.i.get() == null) {
|
||||
this.c.add(new IllegalStateException("onSubscribe not called in proper order"));
|
||||
}
|
||||
}
|
||||
Thread.currentThread();
|
||||
if (this.g != 2) {
|
||||
this.b.add(t);
|
||||
if (t == null) {
|
||||
this.c.add(new NullPointerException("onNext received a null value"));
|
||||
}
|
||||
this.h.onNext(t);
|
||||
return;
|
||||
}
|
||||
while (true) {
|
||||
try {
|
||||
T poll = this.j.poll();
|
||||
if (poll == null) {
|
||||
return;
|
||||
} else {
|
||||
this.b.add(poll);
|
||||
}
|
||||
} catch (Throwable th) {
|
||||
this.c.add(th);
|
||||
this.j.dispose();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.Observer
|
||||
public void onSubscribe(Disposable disposable) {
|
||||
Thread.currentThread();
|
||||
if (disposable == null) {
|
||||
this.c.add(new NullPointerException("onSubscribe received a null Subscription"));
|
||||
return;
|
||||
}
|
||||
if (!this.i.compareAndSet(null, disposable)) {
|
||||
disposable.dispose();
|
||||
if (this.i.get() != DisposableHelper.DISPOSED) {
|
||||
this.c.add(new IllegalStateException("onSubscribe received multiple subscriptions: " + disposable));
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
int i = this.f;
|
||||
if (i != 0 && (disposable instanceof QueueDisposable)) {
|
||||
this.j = (QueueDisposable) disposable;
|
||||
int requestFusion = this.j.requestFusion(i);
|
||||
this.g = requestFusion;
|
||||
if (requestFusion == 1) {
|
||||
this.e = true;
|
||||
Thread.currentThread();
|
||||
while (true) {
|
||||
try {
|
||||
T poll = this.j.poll();
|
||||
if (poll == null) {
|
||||
this.d++;
|
||||
this.i.lazySet(DisposableHelper.DISPOSED);
|
||||
return;
|
||||
}
|
||||
this.b.add(poll);
|
||||
} catch (Throwable th) {
|
||||
this.c.add(th);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.h.onSubscribe(disposable);
|
||||
}
|
||||
|
||||
@Override // io.reactivex.MaybeObserver
|
||||
public void onSuccess(T t) {
|
||||
onNext(t);
|
||||
onComplete();
|
||||
}
|
||||
|
||||
public TestObserver(Observer<? super T> observer) {
|
||||
this.i = new AtomicReference<>();
|
||||
this.h = observer;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user