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

142 lines
4.1 KiB
Java

package o;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.atomic.AtomicReferenceArray;
/* renamed from: o.fYy, reason: case insensitive filesystem */
/* loaded from: classes6.dex */
public final class RunnableC13386fYy extends AtomicReferenceArray<Object> implements Runnable, Callable<Object>, fSJ {
private Runnable a;
private static Object e = new Object();
private static Object c = new Object();
private static Object b = new Object();
private static Object d = new Object();
public RunnableC13386fYy(Runnable runnable, InterfaceC13145fSF interfaceC13145fSF) {
super(3);
this.a = runnable;
lazySet(0, interfaceC13145fSF);
}
@Override // java.util.concurrent.Callable
public final Object call() {
run();
return null;
}
@Override // java.lang.Runnable
public final void run() {
Object obj;
Object obj2;
lazySet(2, Thread.currentThread());
try {
this.a.run();
Object obj3 = get(0);
if (obj3 != e && compareAndSet(0, obj3, d) && obj3 != null) {
((InterfaceC13145fSF) obj3).b(this);
}
do {
obj2 = get(1);
if (obj2 == c || obj2 == b) {
break;
}
} while (!compareAndSet(1, obj2, d));
lazySet(2, null);
} catch (Throwable th) {
try {
C13418fZu.c(th);
throw th;
} catch (Throwable th2) {
Object obj4 = get(0);
if (obj4 != e && compareAndSet(0, obj4, d) && obj4 != null) {
((InterfaceC13145fSF) obj4).b(this);
}
do {
obj = get(1);
if (obj == c || obj == b) {
break;
}
} while (!compareAndSet(1, obj, d));
lazySet(2, null);
throw th2;
}
}
}
public final void e(Future<?> future) {
Object obj;
do {
obj = get(1);
if (obj == d) {
return;
}
if (obj == c) {
future.cancel(false);
return;
} else if (obj == b) {
future.cancel(true);
return;
}
} while (!compareAndSet(1, obj, future));
}
@Override // o.fSJ
public final void dispose() {
Object obj;
Object obj2;
Object obj3;
Object obj4;
while (true) {
Object obj5 = get(1);
if (obj5 == d || obj5 == (obj3 = c) || obj5 == (obj4 = b)) {
break;
}
boolean z = get(2) != Thread.currentThread();
if (z) {
obj3 = obj4;
}
if (compareAndSet(1, obj5, obj3)) {
if (obj5 != null) {
((Future) obj5).cancel(z);
}
}
}
do {
obj = get(0);
if (obj == d || obj == (obj2 = e) || obj == null) {
return;
}
} while (!compareAndSet(0, obj, obj2));
((InterfaceC13145fSF) obj).b(this);
}
@Override // o.fSJ
public final boolean isDisposed() {
Object obj = get(0);
return obj == e || obj == d;
}
@Override // java.util.concurrent.atomic.AtomicReferenceArray
public final String toString() {
String concat;
Object obj = get(1);
if (obj == d) {
concat = "Finished";
} else if (obj == c) {
concat = "Disposed(Sync)";
} else if (obj == b) {
concat = "Disposed(Async)";
} else {
Object obj2 = get(2);
concat = obj2 == null ? "Waiting" : "Running on ".concat(String.valueOf(obj2));
}
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append("[");
sb.append(concat);
sb.append("]");
return sb.toString();
}
}