what-the-bank/sources/o/AbstractC13379fYr.java

83 lines
2.4 KiB
Java

package o;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;
import java.util.concurrent.atomic.AtomicReference;
/* JADX INFO: Access modifiers changed from: package-private */
/* renamed from: o.fYr, reason: case insensitive filesystem */
/* loaded from: classes6.dex */
public abstract class AbstractC13379fYr extends AtomicReference<Future<?>> implements fSJ {
protected final Runnable b;
protected Thread c;
private boolean e = true;
protected static final FutureTask<Void> d = new FutureTask<>(C13194fTh.d, null);
private static FutureTask<Void> a = new FutureTask<>(C13194fTh.d, null);
/* JADX INFO: Access modifiers changed from: package-private */
public AbstractC13379fYr(Runnable runnable) {
this.b = runnable;
}
@Override // o.fSJ
public final void dispose() {
FutureTask<Void> futureTask;
Future<?> future = get();
if (future == d || future == (futureTask = a) || !compareAndSet(future, futureTask) || future == null) {
return;
}
b(future);
}
@Override // o.fSJ
public final boolean isDisposed() {
Future<?> future = get();
return future == d || future == a;
}
public final void e(Future<?> future) {
Future<?> future2;
do {
future2 = get();
if (future2 == d) {
return;
}
if (future2 == a) {
b(future);
return;
}
} while (!compareAndSet(future2, future));
}
private void b(Future<?> future) {
if (this.c == Thread.currentThread()) {
future.cancel(false);
} else {
future.cancel(this.e);
}
}
@Override // java.util.concurrent.atomic.AtomicReference
public String toString() {
String str;
Future<?> future = get();
if (future == d) {
str = "Finished";
} else if (future == a) {
str = "Disposed";
} else if (this.c != null) {
StringBuilder sb = new StringBuilder("Running on ");
sb.append(this.c);
str = sb.toString();
} else {
str = "Waiting";
}
StringBuilder sb2 = new StringBuilder();
sb2.append(getClass().getSimpleName());
sb2.append("[");
sb2.append(str);
sb2.append("]");
return sb2.toString();
}
}