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

564 lines
21 KiB
Java
Raw Permalink Normal View History

2024-07-27 18:17:47 +07:00
package o;
import java.util.concurrent.CancellationException;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import kotlinx.coroutines.CompletionHandlerException;
/* loaded from: classes.dex */
public class geA<T> extends AbstractC15050gfj<T> implements InterfaceC15027gev<T>, InterfaceC14922gbx {
volatile int _decision;
public volatile Object _state;
private final InterfaceC14912gbn b;
public InterfaceC15056gfp e;
private final InterfaceC14907gbi<T> h;
private static final AtomicIntegerFieldUpdater c = AtomicIntegerFieldUpdater.newUpdater(geA.class, "_decision");
private static final AtomicReferenceFieldUpdater a = AtomicReferenceFieldUpdater.newUpdater(geA.class, Object.class, "_state");
@Override // o.InterfaceC14922gbx
public StackTraceElement getStackTraceElement() {
return null;
}
/* JADX WARN: Multi-variable type inference failed */
public geA(InterfaceC14907gbi<? super T> interfaceC14907gbi, int i) {
super(i);
this.h = interfaceC14907gbi;
C15045gfe.b();
this.b = interfaceC14907gbi.getContext();
this._decision = 0;
this._state = C15024ges.e;
}
private final boolean j() {
return this.d == 2 && ((ggM) this.h)._reusableCancellableContinuation != null;
}
@Override // o.InterfaceC14922gbx
public InterfaceC14922gbx getCallerFrame() {
InterfaceC14907gbi<T> interfaceC14907gbi = this.h;
if (interfaceC14907gbi instanceof InterfaceC14922gbx) {
return (InterfaceC14922gbx) interfaceC14907gbi;
}
return null;
}
@Override // o.AbstractC15050gfj
public final void d(Object obj, Throwable th) {
while (true) {
Object obj2 = this._state;
if (obj2 instanceof gfO) {
throw new IllegalStateException("Not completed".toString());
}
if (obj2 instanceof C15000geK) {
return;
}
if (obj2 instanceof geH) {
geH geh = (geH) obj2;
if (!(!(geh.e != null))) {
throw new IllegalStateException("Must be called at most once".toString());
}
geH a2 = geH.a(geh, null, null, null, null, th, 15);
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = a;
while (!atomicReferenceFieldUpdater.compareAndSet(this, obj2, a2)) {
if (atomicReferenceFieldUpdater.get(this) != obj2) {
break;
}
}
AbstractC15029gex abstractC15029gex = geh.d;
if (abstractC15029gex != null) {
e(abstractC15029gex, th);
}
InterfaceC14894gbR<Throwable, C14866gag> interfaceC14894gbR = geh.a;
if (interfaceC14894gbR != null) {
e(interfaceC14894gbR, th);
return;
}
return;
}
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater2 = a;
geH geh2 = new geH(obj2, null, null, null, th, 14);
while (!atomicReferenceFieldUpdater2.compareAndSet(this, obj2, geh2)) {
if (atomicReferenceFieldUpdater2.get(this) != obj2) {
break;
}
}
return;
}
}
private boolean e(Throwable th) {
while (true) {
Object obj = this._state;
if (!(obj instanceof gfO)) {
return false;
}
boolean z = obj instanceof AbstractC15029gex;
C15030gey c15030gey = new C15030gey(this, th, z);
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = a;
while (!atomicReferenceFieldUpdater.compareAndSet(this, obj, c15030gey)) {
if (atomicReferenceFieldUpdater.get(this) != obj) {
break;
}
}
AbstractC15029gex abstractC15029gex = z ? (AbstractC15029gex) obj : null;
if (abstractC15029gex != null) {
e(abstractC15029gex, th);
}
g();
c(this.d);
return true;
}
}
private void e(AbstractC15029gex abstractC15029gex, Throwable th) {
try {
abstractC15029gex.e(th);
} catch (Throwable th2) {
geO.b(getContext(), new CompletionHandlerException("Exception in invokeOnCancellation handler for ".concat(String.valueOf(this)), th2));
}
}
private void e(InterfaceC14894gbR<? super Throwable, C14866gag> interfaceC14894gbR, Throwable th) {
try {
interfaceC14894gbR.invoke(th);
} catch (Throwable th2) {
geO.b(getContext(), new CompletionHandlerException("Exception in resume onCancellation handler for ".concat(String.valueOf(this)), th2));
}
}
public static Throwable b(InterfaceC15034gfD interfaceC15034gfD) {
return interfaceC15034gfD.e();
}
private final boolean i() {
do {
int i = this._decision;
if (i != 0) {
if (i == 2) {
return false;
}
throw new IllegalStateException("Already suspended".toString());
}
} while (!c.compareAndSet(this, 0, 1));
return true;
}
public final Object e() {
InterfaceC15034gfD interfaceC15034gfD;
boolean j = j();
if (i()) {
if (this.e == null) {
a();
}
if (j) {
f();
}
return EnumC14910gbl.COROUTINE_SUSPENDED;
}
if (j) {
f();
}
Object obj = this._state;
if (!(obj instanceof C15000geK)) {
int i = this.d;
if ((i != 1 && i != 2) || (interfaceC15034gfD = (InterfaceC15034gfD) getContext().get(InterfaceC15034gfD.d)) == null || interfaceC15034gfD.d()) {
return obj instanceof geH ? ((geH) obj).c : obj;
}
CancellationException e = interfaceC15034gfD.e();
d(obj, e);
if (!C15045gfe.a()) {
throw e;
}
geA<T> gea = this;
if (gea instanceof InterfaceC14922gbx) {
throw C15120ghi.c(e, gea);
}
throw e;
}
Throwable th = ((C15000geK) obj).d;
if (!C15045gfe.a()) {
throw th;
}
geA<T> gea2 = this;
if (gea2 instanceof InterfaceC14922gbx) {
throw C15120ghi.c(th, gea2);
}
throw th;
}
public final InterfaceC15056gfp a() {
InterfaceC15034gfD interfaceC15034gfD = (InterfaceC15034gfD) getContext().get(InterfaceC15034gfD.d);
if (interfaceC15034gfD == null) {
return null;
}
InterfaceC15056gfp c2 = interfaceC15034gfD.c(true, true, new C15031gez(this));
this.e = c2;
return c2;
}
private final void f() {
InterfaceC14907gbi<T> interfaceC14907gbi = this.h;
Throwable th = null;
ggM ggm = interfaceC14907gbi instanceof ggM ? (ggM) interfaceC14907gbi : null;
if (ggm != null) {
geA<T> gea = this;
loop0: while (true) {
Object obj = ggm._reusableCancellableContinuation;
if (obj == C15069ggJ.b) {
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = ggM.c;
C15119ghh c15119ghh = C15069ggJ.b;
while (!atomicReferenceFieldUpdater.compareAndSet(ggm, c15119ghh, gea)) {
if (atomicReferenceFieldUpdater.get(ggm) != c15119ghh) {
break;
}
}
break loop0;
}
if (!(obj instanceof Throwable)) {
throw new IllegalStateException("Inconsistent state ".concat(String.valueOf(obj)).toString());
}
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater2 = ggM.c;
while (!atomicReferenceFieldUpdater2.compareAndSet(ggm, obj, null)) {
if (atomicReferenceFieldUpdater2.get(ggm) != obj) {
throw new IllegalArgumentException("Failed requirement.".toString());
}
}
th = (Throwable) obj;
}
if (th != null) {
InterfaceC15056gfp interfaceC15056gfp = this.e;
if (interfaceC15056gfp != null) {
interfaceC15056gfp.e();
this.e = gfL.d;
}
e(th);
}
}
}
@Override // o.InterfaceC14907gbi
public void resumeWith(Object obj) {
geA<T> gea = this;
Throwable d = C13395fZS.d(obj);
if (d != null) {
if (C15045gfe.a()) {
d = C15120ghi.c(d, gea);
}
obj = new C15000geK(d);
}
e(obj, this.d, null);
}
@Override // o.InterfaceC15027gev
public final void b(T t, InterfaceC14894gbR<? super Throwable, C14866gag> interfaceC14894gbR) {
e(t, this.d, interfaceC14894gbR);
}
private static void d(InterfaceC14894gbR<? super Throwable, C14866gag> interfaceC14894gbR, Object obj) {
StringBuilder sb = new StringBuilder("It's prohibited to register multiple handlers, tried to register ");
sb.append(interfaceC14894gbR);
sb.append(", already has ");
sb.append(obj);
throw new IllegalStateException(sb.toString().toString());
}
private final void c(int i) {
AbstractC15050gfj<?> c2;
do {
int i2 = this._decision;
if (i2 != 0) {
if (i2 == 1) {
geA<T> gea = this;
C15045gfe.b();
InterfaceC14907gbi<T> b = gea.b();
boolean z = i == 4;
if (!z && (b instanceof ggM)) {
boolean z2 = i == 1 || i == 2;
int i3 = gea.d;
if (z2 == (i3 == 1 || i3 == 2)) {
AbstractC15004geU abstractC15004geU = ((ggM) b).h;
InterfaceC14912gbn context = b.getContext();
if (abstractC15004geU.c()) {
abstractC15004geU.d(context, gea);
return;
}
C15039gfT c15039gfT = C15039gfT.e;
AbstractC15057gfq d = C15039gfT.d();
if (d.b >= AbstractC15057gfq.d()) {
ggE<AbstractC15050gfj<?>> gge = d.e;
if (gge == null) {
gge = new ggE<>();
d.e = gge;
}
gge.b(gea);
return;
}
d.b += AbstractC15057gfq.d();
try {
C15049gfi.a(gea, gea.b(), true);
while (true) {
ggE<AbstractC15050gfj<?>> gge2 = d.e;
if (gge2 != null && (c2 = gge2.c()) != null) {
c2.run();
}
}
} finally {
try {
return;
} finally {
}
}
return;
}
}
C15049gfi.a(gea, b, z);
return;
}
throw new IllegalStateException("Already resumed".toString());
}
} while (!c.compareAndSet(this, 0, 2));
}
private static Object a(gfO gfo, Object obj, int i, InterfaceC14894gbR<? super Throwable, C14866gag> interfaceC14894gbR, Object obj2) {
if (obj instanceof C15000geK) {
C15045gfe.b();
C15045gfe.b();
return obj;
}
if (i != 1 && i != 2 && obj2 == null) {
return obj;
}
if (interfaceC14894gbR != null || (((gfo instanceof AbstractC15029gex) && !(gfo instanceof AbstractC15021gep)) || obj2 != null)) {
return new geH(obj, gfo instanceof AbstractC15029gex ? (AbstractC15029gex) gfo : null, interfaceC14894gbR, obj2, null, 16);
}
return obj;
}
private final void e(Object obj, int i, InterfaceC14894gbR<? super Throwable, C14866gag> interfaceC14894gbR) {
while (true) {
Object obj2 = this._state;
if (obj2 instanceof gfO) {
Object a2 = a((gfO) obj2, obj, i, interfaceC14894gbR, null);
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = a;
while (!atomicReferenceFieldUpdater.compareAndSet(this, obj2, a2)) {
if (atomicReferenceFieldUpdater.get(this) != obj2) {
break;
}
}
g();
c(i);
return;
}
if (obj2 instanceof C15030gey) {
C15030gey c15030gey = (C15030gey) obj2;
if (C15030gey.a.compareAndSet(c15030gey, 0, 1)) {
if (interfaceC14894gbR != null) {
e(interfaceC14894gbR, c15030gey.d);
return;
}
return;
}
}
throw new IllegalStateException("Already resumed, but proposed with update ".concat(String.valueOf(obj)).toString());
}
}
private final C15119ghh b(Object obj, Object obj2, InterfaceC14894gbR<? super Throwable, C14866gag> interfaceC14894gbR) {
while (true) {
Object obj3 = this._state;
if (!(obj3 instanceof gfO)) {
return null;
}
Object a2 = a((gfO) obj3, obj, this.d, interfaceC14894gbR, null);
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = a;
while (!atomicReferenceFieldUpdater.compareAndSet(this, obj3, a2)) {
if (atomicReferenceFieldUpdater.get(this) != obj3) {
break;
}
}
g();
return geC.b;
}
}
@Override // o.InterfaceC15027gev
public final Object c(T t) {
return b(t, null, null);
}
@Override // o.InterfaceC15027gev
public final Object c(T t, InterfaceC14894gbR<? super Throwable, C14866gag> interfaceC14894gbR) {
return b(t, null, interfaceC14894gbR);
}
@Override // o.InterfaceC15027gev
public final void c() {
C15045gfe.b();
c(this.d);
}
/* JADX WARN: Multi-variable type inference failed */
@Override // o.AbstractC15050gfj
public final <T> T d(Object obj) {
return obj instanceof geH ? (T) ((geH) obj).c : obj;
}
@Override // o.AbstractC15050gfj
public final Throwable b(Object obj) {
Throwable b = super.b(obj);
if (b == null) {
return null;
}
InterfaceC14907gbi<T> interfaceC14907gbi = this.h;
return (C15045gfe.a() && (interfaceC14907gbi instanceof InterfaceC14922gbx)) ? C15120ghi.c(b, (InterfaceC14922gbx) interfaceC14907gbi) : b;
}
public String toString() {
String str;
StringBuilder sb = new StringBuilder("CancellableContinuation(");
sb.append(C15041gfa.c(this.h));
sb.append("){");
Object obj = this._state;
if (obj instanceof gfO) {
str = "Active";
} else {
str = obj instanceof C15030gey ? "Cancelled" : "Completed";
}
sb.append(str);
sb.append("}@");
sb.append(C15041gfa.b(this));
return sb.toString();
}
private final void a(InterfaceC14894gbR<? super Throwable, C14866gag> interfaceC14894gbR, Throwable th) {
try {
interfaceC14894gbR.invoke(th);
} catch (Throwable th2) {
geO.b(getContext(), new CompletionHandlerException("Exception in invokeOnCancellation handler for ".concat(String.valueOf(this)), th2));
}
}
private final void g() {
InterfaceC15056gfp interfaceC15056gfp;
if ((this.d != 2 || ((ggM) this.h)._reusableCancellableContinuation == null) && (interfaceC15056gfp = this.e) != null) {
interfaceC15056gfp.e();
this.e = gfL.d;
}
}
@Override // o.InterfaceC15027gev
public final void e(InterfaceC14894gbR<? super Throwable, C14866gag> interfaceC14894gbR) {
C15065gfy c15065gfy = interfaceC14894gbR instanceof AbstractC15029gex ? (AbstractC15029gex) interfaceC14894gbR : new C15065gfy(interfaceC14894gbR);
while (true) {
Object obj = this._state;
if (!(obj instanceof C15024ges)) {
if (!(obj instanceof AbstractC15029gex)) {
boolean z = obj instanceof C15000geK;
if (z) {
C15000geK c15000geK = (C15000geK) obj;
if (!C15000geK.c.compareAndSet(c15000geK, 0, 1)) {
d(interfaceC14894gbR, obj);
}
if (obj instanceof C15030gey) {
if (!z) {
c15000geK = null;
}
a(interfaceC14894gbR, c15000geK != null ? c15000geK.d : null);
return;
}
return;
}
if (obj instanceof geH) {
geH geh = (geH) obj;
if (geh.d != null) {
d(interfaceC14894gbR, obj);
}
if (c15065gfy instanceof AbstractC15021gep) {
return;
}
if (geh.e != null) {
a(interfaceC14894gbR, geh.e);
return;
}
geH a2 = geH.a(geh, null, c15065gfy, null, null, null, 29);
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = a;
while (!atomicReferenceFieldUpdater.compareAndSet(this, obj, a2)) {
if (atomicReferenceFieldUpdater.get(this) != obj) {
break;
}
}
return;
}
if (c15065gfy instanceof AbstractC15021gep) {
return;
}
geH geh2 = new geH(obj, c15065gfy, null, null, null, 28);
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater2 = a;
while (!atomicReferenceFieldUpdater2.compareAndSet(this, obj, geh2)) {
if (atomicReferenceFieldUpdater2.get(this) != obj) {
break;
}
}
return;
}
d(interfaceC14894gbR, obj);
} else {
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater3 = a;
while (!atomicReferenceFieldUpdater3.compareAndSet(this, obj, c15065gfy)) {
if (atomicReferenceFieldUpdater3.get(this) != obj) {
break;
}
}
return;
}
}
}
public final void b(Throwable th) {
if (j()) {
ggM ggm = (ggM) this.h;
loop0: while (true) {
Object obj = ggm._reusableCancellableContinuation;
if (C14957gcv.b(obj, C15069ggJ.b)) {
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = ggM.c;
C15119ghh c15119ghh = C15069ggJ.b;
while (!atomicReferenceFieldUpdater.compareAndSet(ggm, c15119ghh, th)) {
if (atomicReferenceFieldUpdater.get(ggm) != c15119ghh) {
break;
}
}
return;
}
if (!(obj instanceof Throwable)) {
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater2 = ggM.c;
while (!atomicReferenceFieldUpdater2.compareAndSet(ggm, obj, null)) {
if (atomicReferenceFieldUpdater2.get(ggm) != obj) {
break;
}
}
break loop0;
}
return;
}
}
e(th);
g();
}
@Override // o.AbstractC15050gfj
public final Object d() {
return this._state;
}
@Override // o.AbstractC15050gfj
public final InterfaceC14907gbi<T> b() {
return this.h;
}
@Override // o.InterfaceC14907gbi
public InterfaceC14912gbn getContext() {
return this.b;
}
}