Initial commit
This commit is contained in:
135
sources/io/reactivex/disposables/CompositeDisposable.java
Normal file
135
sources/io/reactivex/disposables/CompositeDisposable.java
Normal file
@@ -0,0 +1,135 @@
|
||||
package io.reactivex.disposables;
|
||||
|
||||
import io.reactivex.exceptions.CompositeException;
|
||||
import io.reactivex.exceptions.Exceptions;
|
||||
import io.reactivex.internal.disposables.DisposableContainer;
|
||||
import io.reactivex.internal.functions.ObjectHelper;
|
||||
import io.reactivex.internal.util.ExceptionHelper;
|
||||
import io.reactivex.internal.util.OpenHashSet;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class CompositeDisposable implements Disposable, DisposableContainer {
|
||||
OpenHashSet<Disposable> a;
|
||||
volatile boolean b;
|
||||
|
||||
@Override // io.reactivex.internal.disposables.DisposableContainer
|
||||
public boolean a(Disposable disposable) {
|
||||
if (!c(disposable)) {
|
||||
return false;
|
||||
}
|
||||
disposable.dispose();
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean b() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
@Override // io.reactivex.internal.disposables.DisposableContainer
|
||||
public boolean c(Disposable disposable) {
|
||||
ObjectHelper.a(disposable, "Disposable item is null");
|
||||
if (this.b) {
|
||||
return false;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (this.b) {
|
||||
return false;
|
||||
}
|
||||
OpenHashSet<Disposable> openHashSet = this.a;
|
||||
if (openHashSet != null && openHashSet.b(disposable)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.disposables.Disposable
|
||||
public void dispose() {
|
||||
if (this.b) {
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (this.b) {
|
||||
return;
|
||||
}
|
||||
this.b = true;
|
||||
OpenHashSet<Disposable> openHashSet = this.a;
|
||||
this.a = null;
|
||||
a(openHashSet);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // io.reactivex.internal.disposables.DisposableContainer
|
||||
public boolean b(Disposable disposable) {
|
||||
ObjectHelper.a(disposable, "d is null");
|
||||
if (!this.b) {
|
||||
synchronized (this) {
|
||||
if (!this.b) {
|
||||
OpenHashSet<Disposable> openHashSet = this.a;
|
||||
if (openHashSet == null) {
|
||||
openHashSet = new OpenHashSet<>();
|
||||
this.a = openHashSet;
|
||||
}
|
||||
openHashSet.a((OpenHashSet<Disposable>) disposable);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
disposable.dispose();
|
||||
return false;
|
||||
}
|
||||
|
||||
public void a() {
|
||||
if (this.b) {
|
||||
return;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (this.b) {
|
||||
return;
|
||||
}
|
||||
OpenHashSet<Disposable> openHashSet = this.a;
|
||||
this.a = null;
|
||||
a(openHashSet);
|
||||
}
|
||||
}
|
||||
|
||||
public int c() {
|
||||
if (this.b) {
|
||||
return 0;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (this.b) {
|
||||
return 0;
|
||||
}
|
||||
OpenHashSet<Disposable> openHashSet = this.a;
|
||||
return openHashSet != null ? openHashSet.c() : 0;
|
||||
}
|
||||
}
|
||||
|
||||
void a(OpenHashSet<Disposable> openHashSet) {
|
||||
if (openHashSet == null) {
|
||||
return;
|
||||
}
|
||||
ArrayList arrayList = null;
|
||||
for (Object obj : openHashSet.a()) {
|
||||
if (obj instanceof Disposable) {
|
||||
try {
|
||||
((Disposable) obj).dispose();
|
||||
} catch (Throwable th) {
|
||||
Exceptions.b(th);
|
||||
if (arrayList == null) {
|
||||
arrayList = new ArrayList();
|
||||
}
|
||||
arrayList.add(th);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (arrayList != null) {
|
||||
if (arrayList.size() == 1) {
|
||||
throw ExceptionHelper.a((Throwable) arrayList.get(0));
|
||||
}
|
||||
throw new CompositeException(arrayList);
|
||||
}
|
||||
}
|
||||
}
|
6
sources/io/reactivex/disposables/Disposable.java
Normal file
6
sources/io/reactivex/disposables/Disposable.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package io.reactivex.disposables;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public interface Disposable {
|
||||
void dispose();
|
||||
}
|
21
sources/io/reactivex/disposables/Disposables.java
Normal file
21
sources/io/reactivex/disposables/Disposables.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package io.reactivex.disposables;
|
||||
|
||||
import io.reactivex.internal.disposables.EmptyDisposable;
|
||||
import io.reactivex.internal.functions.Functions;
|
||||
import io.reactivex.internal.functions.ObjectHelper;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
public final class Disposables {
|
||||
public static Disposable a(Runnable runnable) {
|
||||
ObjectHelper.a(runnable, "run is null");
|
||||
return new RunnableDisposable(runnable);
|
||||
}
|
||||
|
||||
public static Disposable b() {
|
||||
return a(Functions.b);
|
||||
}
|
||||
|
||||
public static Disposable a() {
|
||||
return EmptyDisposable.INSTANCE;
|
||||
}
|
||||
}
|
28
sources/io/reactivex/disposables/ReferenceDisposable.java
Normal file
28
sources/io/reactivex/disposables/ReferenceDisposable.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package io.reactivex.disposables;
|
||||
|
||||
import io.reactivex.internal.functions.ObjectHelper;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
abstract class ReferenceDisposable<T> extends AtomicReference<T> implements Disposable {
|
||||
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
|
||||
ReferenceDisposable(T t) {
|
||||
super(t);
|
||||
ObjectHelper.a((Object) t, "value is null");
|
||||
}
|
||||
|
||||
protected abstract void a(T t);
|
||||
|
||||
public final boolean a() {
|
||||
return get() == null;
|
||||
}
|
||||
|
||||
@Override // io.reactivex.disposables.Disposable
|
||||
public final void dispose() {
|
||||
T andSet;
|
||||
if (get() == null || (andSet = getAndSet(null)) == null) {
|
||||
return;
|
||||
}
|
||||
a(andSet);
|
||||
}
|
||||
}
|
19
sources/io/reactivex/disposables/RunnableDisposable.java
Normal file
19
sources/io/reactivex/disposables/RunnableDisposable.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package io.reactivex.disposables;
|
||||
|
||||
/* loaded from: classes2.dex */
|
||||
final class RunnableDisposable extends ReferenceDisposable<Runnable> {
|
||||
RunnableDisposable(Runnable runnable) {
|
||||
super(runnable);
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.atomic.AtomicReference
|
||||
public String toString() {
|
||||
return "RunnableDisposable(disposed=" + a() + ", " + get() + ")";
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // io.reactivex.disposables.ReferenceDisposable
|
||||
public void a(Runnable runnable) {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user