158 lines
5.0 KiB
Java
158 lines
5.0 KiB
Java
package j0.l.c;
|
|
|
|
import j0.o.l;
|
|
import java.util.List;
|
|
import java.util.concurrent.Future;
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
import rx.Subscription;
|
|
import rx.exceptions.OnErrorNotImplementedException;
|
|
import rx.functions.Action0;
|
|
import rx.internal.util.SubscriptionList;
|
|
import rx.subscriptions.CompositeSubscription;
|
|
/* compiled from: ScheduledAction */
|
|
public final class j extends AtomicReference<Thread> implements Runnable, Subscription {
|
|
private static final long serialVersionUID = -3962399486978279857L;
|
|
public final Action0 action;
|
|
public final SubscriptionList cancel;
|
|
|
|
/* compiled from: ScheduledAction */
|
|
public final class a implements Subscription {
|
|
public final Future<?> i;
|
|
|
|
public a(Future<?> future) {
|
|
this.i = future;
|
|
}
|
|
|
|
@Override // rx.Subscription
|
|
public boolean isUnsubscribed() {
|
|
return this.i.isCancelled();
|
|
}
|
|
|
|
@Override // rx.Subscription
|
|
public void unsubscribe() {
|
|
if (j.this.get() != Thread.currentThread()) {
|
|
this.i.cancel(true);
|
|
} else {
|
|
this.i.cancel(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* compiled from: ScheduledAction */
|
|
public static final class b extends AtomicBoolean implements Subscription {
|
|
private static final long serialVersionUID = 247232374289553518L;
|
|
public final SubscriptionList parent;
|
|
|
|
/* renamed from: s reason: collision with root package name */
|
|
public final j f2847s;
|
|
|
|
public b(j jVar, SubscriptionList subscriptionList) {
|
|
this.f2847s = jVar;
|
|
this.parent = subscriptionList;
|
|
}
|
|
|
|
@Override // rx.Subscription
|
|
public boolean isUnsubscribed() {
|
|
return this.f2847s.cancel.j;
|
|
}
|
|
|
|
@Override // rx.Subscription
|
|
public void unsubscribe() {
|
|
boolean remove;
|
|
if (compareAndSet(false, true)) {
|
|
SubscriptionList subscriptionList = this.parent;
|
|
j jVar = this.f2847s;
|
|
if (!subscriptionList.j) {
|
|
synchronized (subscriptionList) {
|
|
List<Subscription> list = subscriptionList.i;
|
|
if (!subscriptionList.j) {
|
|
if (list != null) {
|
|
remove = list.remove(jVar);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
if (remove) {
|
|
jVar.unsubscribe();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/* compiled from: ScheduledAction */
|
|
public static final class c extends AtomicBoolean implements Subscription {
|
|
private static final long serialVersionUID = 247232374289553518L;
|
|
public final CompositeSubscription parent;
|
|
|
|
/* renamed from: s reason: collision with root package name */
|
|
public final j f2848s;
|
|
|
|
public c(j jVar, CompositeSubscription compositeSubscription) {
|
|
this.f2848s = jVar;
|
|
this.parent = compositeSubscription;
|
|
}
|
|
|
|
@Override // rx.Subscription
|
|
public boolean isUnsubscribed() {
|
|
return this.f2848s.cancel.j;
|
|
}
|
|
|
|
@Override // rx.Subscription
|
|
public void unsubscribe() {
|
|
if (compareAndSet(false, true)) {
|
|
this.parent.c(this.f2848s);
|
|
}
|
|
}
|
|
}
|
|
|
|
public j(Action0 action0) {
|
|
this.action = action0;
|
|
this.cancel = new SubscriptionList();
|
|
}
|
|
|
|
public j(Action0 action0, SubscriptionList subscriptionList) {
|
|
this.action = action0;
|
|
this.cancel = new SubscriptionList(new b(this, subscriptionList));
|
|
}
|
|
|
|
public j(Action0 action0, CompositeSubscription compositeSubscription) {
|
|
this.action = action0;
|
|
this.cancel = new SubscriptionList(new c(this, compositeSubscription));
|
|
}
|
|
|
|
public void a(Future<?> future) {
|
|
this.cancel.a(new a(future));
|
|
}
|
|
|
|
@Override // rx.Subscription
|
|
public boolean isUnsubscribed() {
|
|
return this.cancel.j;
|
|
}
|
|
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
try {
|
|
lazySet(Thread.currentThread());
|
|
this.action.call();
|
|
} catch (OnErrorNotImplementedException e) {
|
|
IllegalStateException illegalStateException = new IllegalStateException("Exception thrown on Scheduler.Worker thread. Add `onError` handling.", e);
|
|
l.b(illegalStateException);
|
|
Thread currentThread = Thread.currentThread();
|
|
currentThread.getUncaughtExceptionHandler().uncaughtException(currentThread, illegalStateException);
|
|
} catch (Throwable th) {
|
|
unsubscribe();
|
|
throw th;
|
|
}
|
|
unsubscribe();
|
|
}
|
|
|
|
@Override // rx.Subscription
|
|
public void unsubscribe() {
|
|
if (!this.cancel.j) {
|
|
this.cancel.unsubscribe();
|
|
}
|
|
}
|
|
}
|