1080 lines
36 KiB
Java
1080 lines
36 KiB
Java
package s.a;
|
|
|
|
import d0.f0.k;
|
|
import d0.l;
|
|
import d0.w.h.a.e;
|
|
import d0.z.d.m;
|
|
import java.util.ArrayList;
|
|
import java.util.Collections;
|
|
import java.util.IdentityHashMap;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.Set;
|
|
import java.util.concurrent.CancellationException;
|
|
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
|
|
import kotlin.Unit;
|
|
import kotlin.coroutines.Continuation;
|
|
import kotlin.coroutines.CoroutineContext;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.functions.Function2;
|
|
import kotlin.sequences.Sequence;
|
|
import kotlinx.coroutines.CompletionHandlerException;
|
|
import kotlinx.coroutines.Job;
|
|
import kotlinx.coroutines.JobCancellationException;
|
|
import kotlinx.coroutines.TimeoutCancellationException;
|
|
import s.a.a.h;
|
|
import s.a.a.i;
|
|
import s.a.a.j;
|
|
import s.a.a.o;
|
|
import s.a.a.s;
|
|
/* compiled from: JobSupport.kt */
|
|
public class e1 implements Job, p, m1 {
|
|
public static final AtomicReferenceFieldUpdater i = AtomicReferenceFieldUpdater.newUpdater(e1.class, Object.class, "_state");
|
|
public volatile Object _parentHandle;
|
|
public volatile Object _state;
|
|
|
|
/* compiled from: JobSupport.kt */
|
|
public static final class a extends d1<Job> {
|
|
public final e1 m;
|
|
public final b n;
|
|
public final o o;
|
|
public final Object p;
|
|
|
|
public a(e1 e1Var, b bVar, o oVar, Object obj) {
|
|
super(oVar.m);
|
|
this.m = e1Var;
|
|
this.n = bVar;
|
|
this.o = oVar;
|
|
this.p = obj;
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
|
|
@Override // kotlin.jvm.functions.Function1
|
|
public /* bridge */ /* synthetic */ Unit invoke(Throwable th) {
|
|
q(th);
|
|
return Unit.a;
|
|
}
|
|
|
|
@Override // s.a.w
|
|
public void q(Throwable th) {
|
|
e1 e1Var = this.m;
|
|
b bVar = this.n;
|
|
o oVar = this.o;
|
|
Object obj = this.p;
|
|
o O = e1Var.O(oVar);
|
|
if (O == null || !e1Var.W(bVar, O, obj)) {
|
|
e1Var.m(e1Var.w(bVar, obj));
|
|
}
|
|
}
|
|
|
|
@Override // s.a.a.j
|
|
public String toString() {
|
|
StringBuilder L = c.d.b.a.a.L("ChildCompletion[");
|
|
L.append(this.o);
|
|
L.append(", ");
|
|
L.append(this.p);
|
|
L.append(']');
|
|
return L.toString();
|
|
}
|
|
}
|
|
|
|
/* compiled from: JobSupport.kt */
|
|
public static final class b implements w0 {
|
|
public volatile Object _exceptionsHolder = null;
|
|
public volatile int _isCompleting;
|
|
public volatile Object _rootCause;
|
|
public final j1 i;
|
|
|
|
public b(j1 j1Var, boolean z2, Throwable th) {
|
|
this.i = j1Var;
|
|
this._isCompleting = z2 ? 1 : 0;
|
|
this._rootCause = th;
|
|
}
|
|
|
|
@Override // s.a.w0
|
|
public boolean a() {
|
|
return ((Throwable) this._rootCause) == null;
|
|
}
|
|
|
|
/* JADX WARNING: Unknown variable types count: 1 */
|
|
public final void b(Throwable th) {
|
|
Throwable th2 = (Throwable) this._rootCause;
|
|
if (th2 == null) {
|
|
this._rootCause = th;
|
|
} else if (th != th2) {
|
|
?? r0 = this._exceptionsHolder;
|
|
if (r0 == 0) {
|
|
this._exceptionsHolder = th;
|
|
} else if (r0 instanceof Throwable) {
|
|
if (th != r0) {
|
|
ArrayList<Throwable> c2 = c();
|
|
c2.add(r0);
|
|
c2.add(th);
|
|
this._exceptionsHolder = c2;
|
|
}
|
|
} else if (r0 instanceof ArrayList) {
|
|
((ArrayList) r0).add(th);
|
|
} else {
|
|
throw new IllegalStateException(c.d.b.a.a.t("State is ", r0).toString());
|
|
}
|
|
}
|
|
}
|
|
|
|
public final ArrayList<Throwable> c() {
|
|
return new ArrayList<>(4);
|
|
}
|
|
|
|
public final boolean d() {
|
|
return ((Throwable) this._rootCause) != null;
|
|
}
|
|
|
|
public final boolean e() {
|
|
return this._exceptionsHolder == f1.e;
|
|
}
|
|
|
|
/* JADX WARNING: Unknown variable types count: 1 */
|
|
public final List<Throwable> f(Throwable th) {
|
|
ArrayList<Throwable> arrayList;
|
|
?? r0 = this._exceptionsHolder;
|
|
if (r0 == 0) {
|
|
arrayList = c();
|
|
} else if (r0 instanceof Throwable) {
|
|
ArrayList<Throwable> c2 = c();
|
|
c2.add(r0);
|
|
arrayList = c2;
|
|
} else if (r0 instanceof ArrayList) {
|
|
arrayList = (ArrayList) r0;
|
|
} else {
|
|
throw new IllegalStateException(c.d.b.a.a.t("State is ", r0).toString());
|
|
}
|
|
Throwable th2 = (Throwable) this._rootCause;
|
|
if (th2 != null) {
|
|
arrayList.add(0, th2);
|
|
}
|
|
if (th != null && (!m.areEqual(th, th2))) {
|
|
arrayList.add(th);
|
|
}
|
|
this._exceptionsHolder = f1.e;
|
|
return arrayList;
|
|
}
|
|
|
|
@Override // s.a.w0
|
|
public j1 getList() {
|
|
return this.i;
|
|
}
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r0v1, resolved type: java.lang.StringBuilder */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX WARNING: Unknown variable types count: 1 */
|
|
public String toString() {
|
|
StringBuilder L = c.d.b.a.a.L("Finishing[cancelling=");
|
|
L.append(d());
|
|
L.append(", completing=");
|
|
L.append((boolean) this._isCompleting);
|
|
L.append(", rootCause=");
|
|
L.append((Throwable) this._rootCause);
|
|
L.append(", exceptions=");
|
|
L.append(this._exceptionsHolder);
|
|
L.append(", list=");
|
|
L.append(this.i);
|
|
L.append(']');
|
|
return L.toString();
|
|
}
|
|
}
|
|
|
|
/* compiled from: LockFreeLinkedList.kt */
|
|
public static final class c extends j.a {
|
|
public final /* synthetic */ e1 d;
|
|
public final /* synthetic */ Object e;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public c(j jVar, j jVar2, e1 e1Var, Object obj) {
|
|
super(jVar2);
|
|
this.d = e1Var;
|
|
this.e = obj;
|
|
}
|
|
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
|
|
@Override // s.a.a.d
|
|
public Object c(j jVar) {
|
|
if (this.d.F() == this.e) {
|
|
return null;
|
|
}
|
|
return i.a;
|
|
}
|
|
}
|
|
|
|
/* compiled from: JobSupport.kt */
|
|
@e(c = "kotlinx.coroutines.JobSupport$children$1", f = "JobSupport.kt", l = {949, 951}, m = "invokeSuspend")
|
|
public static final class d extends d0.w.h.a.j implements Function2<k<? super p>, Continuation<? super Unit>, Object> {
|
|
public Object L$0;
|
|
public Object L$1;
|
|
public Object L$2;
|
|
public Object L$3;
|
|
public Object L$4;
|
|
public Object L$5;
|
|
public int label;
|
|
private k p$;
|
|
public final /* synthetic */ e1 this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public d(e1 e1Var, Continuation continuation) {
|
|
super(2, continuation);
|
|
this.this$0 = e1Var;
|
|
}
|
|
|
|
@Override // d0.w.h.a.a
|
|
public final Continuation<Unit> create(Object obj, Continuation<?> continuation) {
|
|
d dVar = new d(this.this$0, continuation);
|
|
dVar.p$ = (k) obj;
|
|
return dVar;
|
|
}
|
|
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object, java.lang.Object] */
|
|
@Override // kotlin.jvm.functions.Function2
|
|
public final Object invoke(k<? super p> kVar, Continuation<? super Unit> continuation) {
|
|
d dVar = new d(this.this$0, continuation);
|
|
dVar.p$ = kVar;
|
|
return dVar.invokeSuspend(Unit.a);
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:20:0x007f */
|
|
@Override // d0.w.h.a.a
|
|
public final Object invokeSuspend(Object obj) {
|
|
d dVar;
|
|
k kVar;
|
|
Object obj2;
|
|
h hVar;
|
|
h hVar2;
|
|
j jVar;
|
|
Object coroutine_suspended = d0.w.g.c.getCOROUTINE_SUSPENDED();
|
|
int i = this.label;
|
|
if (i == 0) {
|
|
l.throwOnFailure(obj);
|
|
k kVar2 = this.p$;
|
|
Object F = this.this$0.F();
|
|
if (F instanceof o) {
|
|
p pVar = ((o) F).m;
|
|
this.L$0 = kVar2;
|
|
this.L$1 = F;
|
|
this.label = 1;
|
|
if (kVar2.yield(pVar, this) == coroutine_suspended) {
|
|
return coroutine_suspended;
|
|
}
|
|
} else if ((F instanceof w0) && (hVar2 = ((w0) F).getList()) != null) {
|
|
Object i2 = hVar2.i();
|
|
Objects.requireNonNull(i2, "null cannot be cast to non-null type kotlinx.coroutines.internal.Node /* = kotlinx.coroutines.internal.LockFreeLinkedListNode */");
|
|
kVar = kVar2;
|
|
obj2 = F;
|
|
jVar = (j) i2;
|
|
dVar = this;
|
|
hVar = hVar2;
|
|
}
|
|
return Unit.a;
|
|
} else if (i == 1) {
|
|
k kVar3 = (k) this.L$0;
|
|
l.throwOnFailure(obj);
|
|
return Unit.a;
|
|
} else if (i == 2) {
|
|
o oVar = (o) this.L$5;
|
|
jVar = (j) this.L$4;
|
|
hVar2 = (h) this.L$3;
|
|
hVar = (j1) this.L$2;
|
|
obj2 = this.L$1;
|
|
kVar = (k) this.L$0;
|
|
l.throwOnFailure(obj);
|
|
dVar = this;
|
|
jVar = jVar.j();
|
|
} else {
|
|
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
|
|
}
|
|
if (!m.areEqual(jVar, hVar2)) {
|
|
if (jVar instanceof o) {
|
|
o oVar2 = (o) jVar;
|
|
p pVar2 = oVar2.m;
|
|
dVar.L$0 = kVar;
|
|
dVar.L$1 = obj2;
|
|
dVar.L$2 = hVar;
|
|
dVar.L$3 = hVar2;
|
|
dVar.L$4 = jVar;
|
|
dVar.L$5 = oVar2;
|
|
dVar.label = 2;
|
|
if (kVar.yield(pVar2, dVar) == coroutine_suspended) {
|
|
return coroutine_suspended;
|
|
}
|
|
}
|
|
jVar = jVar.j();
|
|
if (!m.areEqual(jVar, hVar2)) {
|
|
}
|
|
}
|
|
return Unit.a;
|
|
}
|
|
}
|
|
|
|
public e1(boolean z2) {
|
|
this._state = z2 ? f1.g : f1.f;
|
|
this._parentHandle = null;
|
|
}
|
|
|
|
public boolean A() {
|
|
return true;
|
|
}
|
|
|
|
@Override // kotlinx.coroutines.Job
|
|
public void B(CancellationException cancellationException) {
|
|
if (cancellationException == null) {
|
|
cancellationException = new JobCancellationException(q(), null, this);
|
|
}
|
|
n(cancellationException);
|
|
}
|
|
|
|
public boolean D() {
|
|
return false;
|
|
}
|
|
|
|
public final j1 E(w0 w0Var) {
|
|
j1 list = w0Var.getList();
|
|
if (list != null) {
|
|
return list;
|
|
}
|
|
if (w0Var instanceof n0) {
|
|
return new j1();
|
|
}
|
|
if (w0Var instanceof d1) {
|
|
S((d1) w0Var);
|
|
return null;
|
|
}
|
|
throw new IllegalStateException(("State should have list: " + w0Var).toString());
|
|
}
|
|
|
|
public final Object F() {
|
|
while (true) {
|
|
Object obj = this._state;
|
|
if (!(obj instanceof o)) {
|
|
return obj;
|
|
}
|
|
((o) obj).a(this);
|
|
}
|
|
}
|
|
|
|
@Override // kotlinx.coroutines.Job
|
|
public final n G(p pVar) {
|
|
k0 x2 = c.q.a.k.a.x(this, true, false, new o(this, pVar), 2, null);
|
|
Objects.requireNonNull(x2, "null cannot be cast to non-null type kotlinx.coroutines.ChildHandle");
|
|
return (n) x2;
|
|
}
|
|
|
|
public boolean H(Throwable th) {
|
|
return false;
|
|
}
|
|
|
|
public void I(Throwable th) {
|
|
throw th;
|
|
}
|
|
|
|
public final void J(Job job) {
|
|
if (job == null) {
|
|
this._parentHandle = k1.i;
|
|
return;
|
|
}
|
|
job.start();
|
|
n G = job.G(this);
|
|
this._parentHandle = G;
|
|
if (!(F() instanceof w0)) {
|
|
G.dispose();
|
|
this._parentHandle = k1.i;
|
|
}
|
|
}
|
|
|
|
public boolean K() {
|
|
return false;
|
|
}
|
|
|
|
public final Object L(Object obj) {
|
|
Object V;
|
|
do {
|
|
V = V(F(), obj);
|
|
if (V == f1.a) {
|
|
String str = "Job " + this + " is already complete or completing, but is being completed with " + obj;
|
|
Throwable th = null;
|
|
if (!(obj instanceof u)) {
|
|
obj = null;
|
|
}
|
|
u uVar = (u) obj;
|
|
if (uVar != null) {
|
|
th = uVar.b;
|
|
}
|
|
throw new IllegalStateException(str, th);
|
|
}
|
|
} while (V == f1.f2868c);
|
|
return V;
|
|
}
|
|
|
|
public final d1<?> M(Function1<? super Throwable, Unit> function1, boolean z2) {
|
|
b1 b1Var = null;
|
|
if (z2) {
|
|
if (function1 instanceof b1) {
|
|
b1Var = function1;
|
|
}
|
|
b1 b1Var2 = b1Var;
|
|
return b1Var2 != null ? b1Var2 : new z0(this, function1);
|
|
}
|
|
if (function1 instanceof d1) {
|
|
b1Var = function1;
|
|
}
|
|
d1<?> d1Var = b1Var;
|
|
return d1Var != null ? d1Var : new a1(this, function1);
|
|
}
|
|
|
|
public String N() {
|
|
return getClass().getSimpleName();
|
|
}
|
|
|
|
public final o O(j jVar) {
|
|
while (jVar.m()) {
|
|
jVar = jVar.k();
|
|
}
|
|
while (true) {
|
|
jVar = jVar.j();
|
|
if (!jVar.m()) {
|
|
if (jVar instanceof o) {
|
|
return (o) jVar;
|
|
}
|
|
if (jVar instanceof j1) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public final void P(j1 j1Var, Throwable th) {
|
|
CompletionHandlerException completionHandlerException = null;
|
|
Object i2 = j1Var.i();
|
|
Objects.requireNonNull(i2, "null cannot be cast to non-null type kotlinx.coroutines.internal.Node /* = kotlinx.coroutines.internal.LockFreeLinkedListNode */");
|
|
for (j jVar = (j) i2; !m.areEqual(jVar, j1Var); jVar = jVar.j()) {
|
|
if (jVar instanceof b1) {
|
|
d1 d1Var = (d1) jVar;
|
|
try {
|
|
d1Var.q(th);
|
|
} catch (Throwable th2) {
|
|
if (completionHandlerException != null) {
|
|
d0.b.addSuppressed(completionHandlerException, th2);
|
|
} else {
|
|
completionHandlerException = new CompletionHandlerException("Exception in completion handler " + d1Var + " for " + this, th2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (completionHandlerException != null) {
|
|
I(completionHandlerException);
|
|
}
|
|
o(th);
|
|
}
|
|
|
|
public void Q(Object obj) {
|
|
}
|
|
|
|
public void R() {
|
|
}
|
|
|
|
public final void S(d1<?> d1Var) {
|
|
j1 j1Var = new j1();
|
|
j.j.lazySet(j1Var, d1Var);
|
|
j.i.lazySet(j1Var, d1Var);
|
|
while (true) {
|
|
if (d1Var.i() == d1Var) {
|
|
if (j.i.compareAndSet(d1Var, d1Var, j1Var)) {
|
|
j1Var.g(d1Var);
|
|
break;
|
|
}
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
i.compareAndSet(this, d1Var, d1Var.j());
|
|
}
|
|
|
|
public final String T(Object obj) {
|
|
if (!(obj instanceof b)) {
|
|
return obj instanceof w0 ? ((w0) obj).a() ? "Active" : "New" : obj instanceof u ? "Cancelled" : "Completed";
|
|
}
|
|
b bVar = (b) obj;
|
|
return bVar.d() ? "Cancelling" : bVar._isCompleting != 0 ? "Completing" : "Active";
|
|
}
|
|
|
|
public final CancellationException U(Throwable th, String str) {
|
|
CancellationException cancellationException = (CancellationException) (!(th instanceof CancellationException) ? null : th);
|
|
if (cancellationException == null) {
|
|
if (str == null) {
|
|
str = q();
|
|
}
|
|
cancellationException = new JobCancellationException(str, th, this);
|
|
}
|
|
return cancellationException;
|
|
}
|
|
|
|
public final Object V(Object obj, Object obj2) {
|
|
Throwable th;
|
|
if (!(obj instanceof w0)) {
|
|
return f1.a;
|
|
}
|
|
boolean z2 = true;
|
|
if (((obj instanceof n0) || (obj instanceof d1)) && !(obj instanceof o) && !(obj2 instanceof u)) {
|
|
w0 w0Var = (w0) obj;
|
|
if (!i.compareAndSet(this, w0Var, obj2 instanceof w0 ? new x0((w0) obj2) : obj2)) {
|
|
z2 = false;
|
|
} else {
|
|
Q(obj2);
|
|
u(w0Var, obj2);
|
|
}
|
|
return z2 ? obj2 : f1.f2868c;
|
|
}
|
|
w0 w0Var2 = (w0) obj;
|
|
j1 E = E(w0Var2);
|
|
if (E == null) {
|
|
return f1.f2868c;
|
|
}
|
|
o oVar = null;
|
|
b bVar = (b) (!(w0Var2 instanceof b) ? null : w0Var2);
|
|
if (bVar == null) {
|
|
bVar = new b(E, false, null);
|
|
}
|
|
synchronized (bVar) {
|
|
if (bVar._isCompleting != 0) {
|
|
return f1.a;
|
|
}
|
|
bVar._isCompleting = 1;
|
|
if (bVar == w0Var2 || i.compareAndSet(this, w0Var2, bVar)) {
|
|
boolean d2 = bVar.d();
|
|
u uVar = (u) (!(obj2 instanceof u) ? null : obj2);
|
|
if (uVar != null) {
|
|
bVar.b(uVar.b);
|
|
}
|
|
th = (Throwable) bVar._rootCause;
|
|
if (!(true ^ d2)) {
|
|
th = null;
|
|
}
|
|
} else {
|
|
return f1.f2868c;
|
|
}
|
|
}
|
|
if (th != null) {
|
|
P(E, th);
|
|
}
|
|
o oVar2 = (o) (!(w0Var2 instanceof o) ? null : w0Var2);
|
|
if (oVar2 != null) {
|
|
oVar = oVar2;
|
|
} else {
|
|
j1 list = w0Var2.getList();
|
|
if (list != null) {
|
|
oVar = O(list);
|
|
}
|
|
}
|
|
return (oVar == null || !W(bVar, oVar, obj2)) ? w(bVar, obj2) : f1.b;
|
|
}
|
|
|
|
public final boolean W(b bVar, o oVar, Object obj) {
|
|
while (c.q.a.k.a.x(oVar.m, false, false, new a(this, bVar, oVar, obj), 1, null) == k1.i) {
|
|
oVar = O(oVar);
|
|
if (oVar == null) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override // kotlinx.coroutines.Job
|
|
public boolean a() {
|
|
Object F = F();
|
|
return (F instanceof w0) && ((w0) F).a();
|
|
}
|
|
|
|
@Override // kotlinx.coroutines.Job
|
|
public final Sequence<Job> d() {
|
|
return d0.f0.l.sequence(new d(this, null));
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX WARNING: Unknown variable types count: 1 */
|
|
@Override // kotlinx.coroutines.Job
|
|
public final k0 f(boolean z2, boolean z3, Function1<? super Throwable, Unit> function1) {
|
|
Throwable th;
|
|
Throwable th2 = null;
|
|
d1<?> d1Var = null;
|
|
while (true) {
|
|
Object F = F();
|
|
if (F instanceof n0) {
|
|
n0 n0Var = (n0) F;
|
|
if (n0Var.i) {
|
|
if (d1Var == null) {
|
|
d1Var = M(function1, z2);
|
|
}
|
|
if (i.compareAndSet(this, F, d1Var)) {
|
|
return d1Var;
|
|
}
|
|
} else {
|
|
j1 j1Var = new j1();
|
|
if (!n0Var.i) {
|
|
j1Var = new v0(j1Var);
|
|
}
|
|
i.compareAndSet(this, n0Var, j1Var);
|
|
}
|
|
} else if (F instanceof w0) {
|
|
j1 list = ((w0) F).getList();
|
|
if (list == null) {
|
|
Objects.requireNonNull(F, "null cannot be cast to non-null type kotlinx.coroutines.JobNode<*>");
|
|
S((d1) F);
|
|
} else {
|
|
k0 k0Var = k1.i;
|
|
if (!z2 || !(F instanceof b)) {
|
|
th = null;
|
|
} else {
|
|
synchronized (F) {
|
|
th = (Throwable) ((b) F)._rootCause;
|
|
if (th == null || ((function1 instanceof o) && ((b) F)._isCompleting == 0)) {
|
|
if (d1Var == null) {
|
|
d1Var = M(function1, z2);
|
|
}
|
|
if (l(F, list, d1Var)) {
|
|
if (th == null) {
|
|
return d1Var;
|
|
}
|
|
k0Var = d1Var;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (th != null) {
|
|
if (z3) {
|
|
function1.invoke(th);
|
|
}
|
|
return k0Var;
|
|
}
|
|
if (d1Var == null) {
|
|
d1Var = M(function1, z2);
|
|
}
|
|
if (l(F, list, d1Var)) {
|
|
return d1Var;
|
|
}
|
|
}
|
|
} else {
|
|
if (z3) {
|
|
if (!(F instanceof u)) {
|
|
F = null;
|
|
}
|
|
u uVar = (u) F;
|
|
if (uVar != null) {
|
|
th2 = uVar.b;
|
|
}
|
|
function1.invoke(th2);
|
|
}
|
|
return k1.i;
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override // kotlin.coroutines.CoroutineContext
|
|
public <R> R fold(R r, Function2<? super R, ? super CoroutineContext.Element, ? extends R> function2) {
|
|
return (R) CoroutineContext.Element.a.fold(this, r, function2);
|
|
}
|
|
|
|
@Override // kotlin.coroutines.CoroutineContext.Element, kotlin.coroutines.CoroutineContext
|
|
public <E extends CoroutineContext.Element> E get(CoroutineContext.Key<E> key) {
|
|
return (E) CoroutineContext.Element.a.get(this, key);
|
|
}
|
|
|
|
@Override // kotlin.coroutines.CoroutineContext.Element
|
|
public final CoroutineContext.Key<?> getKey() {
|
|
return Job.h;
|
|
}
|
|
|
|
public final boolean l(Object obj, j1 j1Var, d1<?> d1Var) {
|
|
int p;
|
|
c cVar = new c(d1Var, d1Var, this, obj);
|
|
do {
|
|
p = j1Var.k().p(d1Var, j1Var, cVar);
|
|
if (p == 1) {
|
|
return true;
|
|
}
|
|
} while (p != 2);
|
|
return false;
|
|
}
|
|
|
|
public void m(Object obj) {
|
|
}
|
|
|
|
@Override // kotlin.coroutines.CoroutineContext
|
|
public CoroutineContext minusKey(CoroutineContext.Key<?> key) {
|
|
return CoroutineContext.Element.a.minusKey(this, key);
|
|
}
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:10:0x0031, code lost:
|
|
r0 = s.a.f1.a;
|
|
*/
|
|
/* JADX WARNING: Removed duplicated region for block: B:78:0x00b9 A[SYNTHETIC] */
|
|
/* JADX WARNING: Removed duplicated region for block: B:84:0x003e A[SYNTHETIC] */
|
|
public final boolean n(Object obj) {
|
|
s sVar;
|
|
boolean z2;
|
|
s sVar2 = f1.a;
|
|
if (D()) {
|
|
while (true) {
|
|
Object F = F();
|
|
if ((F instanceof w0) && (!(F instanceof b) || ((b) F)._isCompleting == 0)) {
|
|
sVar2 = V(F, new u(v(obj), false, 2));
|
|
if (sVar2 != f1.f2868c) {
|
|
break;
|
|
}
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
if (sVar2 == f1.b) {
|
|
return true;
|
|
}
|
|
}
|
|
if (sVar2 == f1.a) {
|
|
Throwable th = null;
|
|
Throwable th2 = null;
|
|
while (true) {
|
|
Object F2 = F();
|
|
if (!(F2 instanceof b)) {
|
|
if (!(F2 instanceof w0)) {
|
|
sVar = f1.d;
|
|
break;
|
|
}
|
|
if (th2 == null) {
|
|
th2 = v(obj);
|
|
}
|
|
w0 w0Var = (w0) F2;
|
|
if (w0Var.a()) {
|
|
j1 E = E(w0Var);
|
|
if (E != null) {
|
|
if (i.compareAndSet(this, w0Var, new b(E, false, th2))) {
|
|
P(E, th2);
|
|
z2 = true;
|
|
if (!z2) {
|
|
sVar = f1.a;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
z2 = false;
|
|
if (!z2) {
|
|
}
|
|
} else {
|
|
Object V = V(F2, new u(th2, false, 2));
|
|
if (V != f1.a) {
|
|
if (V != f1.f2868c) {
|
|
sVar2 = V;
|
|
break;
|
|
}
|
|
} else {
|
|
throw new IllegalStateException(c.d.b.a.a.t("Cannot happen in ", F2).toString());
|
|
}
|
|
}
|
|
} else {
|
|
synchronized (F2) {
|
|
if (((b) F2).e()) {
|
|
sVar = f1.d;
|
|
} else {
|
|
boolean d2 = ((b) F2).d();
|
|
if (obj != null || !d2) {
|
|
if (th2 == null) {
|
|
th2 = v(obj);
|
|
}
|
|
((b) F2).b(th2);
|
|
}
|
|
Throwable th3 = (Throwable) ((b) F2)._rootCause;
|
|
if (!d2) {
|
|
th = th3;
|
|
}
|
|
if (th != null) {
|
|
P(((b) F2).i, th);
|
|
}
|
|
sVar = f1.a;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
sVar2 = sVar;
|
|
}
|
|
if (!(sVar2 == f1.a || sVar2 == f1.b)) {
|
|
if (sVar2 == f1.d) {
|
|
return false;
|
|
}
|
|
m(sVar2);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public final boolean o(Throwable th) {
|
|
if (K()) {
|
|
return true;
|
|
}
|
|
boolean z2 = th instanceof CancellationException;
|
|
n nVar = (n) this._parentHandle;
|
|
return (nVar == null || nVar == k1.i) ? z2 : nVar.h(th) || z2;
|
|
}
|
|
|
|
@Override // kotlinx.coroutines.Job
|
|
public final CancellationException p() {
|
|
Object F = F();
|
|
if (F instanceof b) {
|
|
Throwable th = (Throwable) ((b) F)._rootCause;
|
|
if (th != null) {
|
|
return U(th, getClass().getSimpleName() + " is cancelling");
|
|
}
|
|
throw new IllegalStateException(("Job is still new or active: " + this).toString());
|
|
} else if (F instanceof w0) {
|
|
throw new IllegalStateException(("Job is still new or active: " + this).toString());
|
|
} else if (F instanceof u) {
|
|
return U(((u) F).b, null);
|
|
} else {
|
|
return new JobCancellationException(getClass().getSimpleName() + " has completed normally", null, this);
|
|
}
|
|
}
|
|
|
|
@Override // kotlin.coroutines.CoroutineContext
|
|
public CoroutineContext plus(CoroutineContext coroutineContext) {
|
|
return CoroutineContext.Element.a.plus(this, coroutineContext);
|
|
}
|
|
|
|
public String q() {
|
|
return "Job was cancelled";
|
|
}
|
|
|
|
@Override // s.a.p
|
|
public final void r(m1 m1Var) {
|
|
n(m1Var);
|
|
}
|
|
|
|
public boolean s(Throwable th) {
|
|
if (th instanceof CancellationException) {
|
|
return true;
|
|
}
|
|
return n(th) && A();
|
|
}
|
|
|
|
/* JADX WARNING: Removed duplicated region for block: B:18:0x0040 A[SYNTHETIC] */
|
|
@Override // kotlinx.coroutines.Job
|
|
public final boolean start() {
|
|
char c2;
|
|
do {
|
|
Object F = F();
|
|
c2 = 65535;
|
|
if (F instanceof n0) {
|
|
if (!((n0) F).i) {
|
|
if (i.compareAndSet(this, F, f1.g)) {
|
|
R();
|
|
}
|
|
if (c2 == 0) {
|
|
return false;
|
|
}
|
|
}
|
|
c2 = 0;
|
|
if (c2 == 0) {
|
|
}
|
|
} else {
|
|
if (F instanceof v0) {
|
|
if (i.compareAndSet(this, F, ((v0) F).i)) {
|
|
R();
|
|
}
|
|
if (c2 == 0) {
|
|
}
|
|
}
|
|
c2 = 0;
|
|
if (c2 == 0) {
|
|
}
|
|
}
|
|
c2 = 1;
|
|
if (c2 == 0) {
|
|
}
|
|
} while (c2 != 1);
|
|
return true;
|
|
}
|
|
|
|
@Override // kotlinx.coroutines.Job
|
|
public final k0 t(Function1<? super Throwable, Unit> function1) {
|
|
return f(false, true, function1);
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append(N() + '{' + T(F()) + '}');
|
|
sb.append('@');
|
|
sb.append(c.q.a.k.a.t(this));
|
|
return sb.toString();
|
|
}
|
|
|
|
public final void u(w0 w0Var, Object obj) {
|
|
n nVar = (n) this._parentHandle;
|
|
if (nVar != null) {
|
|
nVar.dispose();
|
|
this._parentHandle = k1.i;
|
|
}
|
|
CompletionHandlerException completionHandlerException = null;
|
|
if (!(obj instanceof u)) {
|
|
obj = null;
|
|
}
|
|
u uVar = (u) obj;
|
|
Throwable th = uVar != null ? uVar.b : null;
|
|
if (w0Var instanceof d1) {
|
|
try {
|
|
((d1) w0Var).q(th);
|
|
} catch (Throwable th2) {
|
|
I(new CompletionHandlerException("Exception in completion handler " + w0Var + " for " + this, th2));
|
|
}
|
|
} else {
|
|
j1 list = w0Var.getList();
|
|
if (list != null) {
|
|
Object i2 = list.i();
|
|
Objects.requireNonNull(i2, "null cannot be cast to non-null type kotlinx.coroutines.internal.Node /* = kotlinx.coroutines.internal.LockFreeLinkedListNode */");
|
|
for (j jVar = (j) i2; !m.areEqual(jVar, list); jVar = jVar.j()) {
|
|
if (jVar instanceof d1) {
|
|
d1 d1Var = (d1) jVar;
|
|
try {
|
|
d1Var.q(th);
|
|
} catch (Throwable th3) {
|
|
if (completionHandlerException != null) {
|
|
d0.b.addSuppressed(completionHandlerException, th3);
|
|
} else {
|
|
completionHandlerException = new CompletionHandlerException("Exception in completion handler " + d1Var + " for " + this, th3);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (completionHandlerException != null) {
|
|
I(completionHandlerException);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public final Throwable v(Object obj) {
|
|
if (obj != null ? obj instanceof Throwable : true) {
|
|
return obj != null ? (Throwable) obj : new JobCancellationException(q(), null, this);
|
|
}
|
|
Objects.requireNonNull(obj, "null cannot be cast to non-null type kotlinx.coroutines.ParentJob");
|
|
return ((m1) obj).z();
|
|
}
|
|
|
|
public final Object w(b bVar, Object obj) {
|
|
Throwable y2;
|
|
Throwable th = null;
|
|
u uVar = (u) (!(obj instanceof u) ? null : obj);
|
|
if (uVar != null) {
|
|
th = uVar.b;
|
|
}
|
|
synchronized (bVar) {
|
|
bVar.d();
|
|
List<Throwable> f = bVar.f(th);
|
|
y2 = y(bVar, f);
|
|
if (y2 != null) {
|
|
if (f.size() > 1) {
|
|
Set newSetFromMap = Collections.newSetFromMap(new IdentityHashMap(f.size()));
|
|
for (Throwable th2 : f) {
|
|
if (th2 != y2 && th2 != y2 && !(th2 instanceof CancellationException) && newSetFromMap.add(th2)) {
|
|
d0.b.addSuppressed(y2, th2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!(y2 == null || y2 == th)) {
|
|
obj = new u(y2, false, 2);
|
|
}
|
|
if (y2 != null) {
|
|
if (o(y2) || H(y2)) {
|
|
Objects.requireNonNull(obj, "null cannot be cast to non-null type kotlinx.coroutines.CompletedExceptionally");
|
|
u.a.compareAndSet((u) obj, 0, 1);
|
|
}
|
|
}
|
|
Q(obj);
|
|
i.compareAndSet(this, bVar, obj instanceof w0 ? new x0((w0) obj) : obj);
|
|
u(bVar, obj);
|
|
return obj;
|
|
}
|
|
|
|
public final Throwable y(b bVar, List<? extends Throwable> list) {
|
|
Object obj;
|
|
boolean z2;
|
|
Object obj2 = null;
|
|
if (!list.isEmpty()) {
|
|
Iterator<T> it = list.iterator();
|
|
while (true) {
|
|
if (!it.hasNext()) {
|
|
obj = null;
|
|
break;
|
|
}
|
|
obj = it.next();
|
|
if (!(((Throwable) obj) instanceof CancellationException)) {
|
|
break;
|
|
}
|
|
}
|
|
Throwable th = (Throwable) obj;
|
|
if (th != null) {
|
|
return th;
|
|
}
|
|
Throwable th2 = (Throwable) list.get(0);
|
|
if (th2 instanceof TimeoutCancellationException) {
|
|
Iterator<T> it2 = list.iterator();
|
|
while (true) {
|
|
if (!it2.hasNext()) {
|
|
break;
|
|
}
|
|
Object next = it2.next();
|
|
Throwable th3 = (Throwable) next;
|
|
if (th3 == th2 || !(th3 instanceof TimeoutCancellationException)) {
|
|
z2 = false;
|
|
continue;
|
|
} else {
|
|
z2 = true;
|
|
continue;
|
|
}
|
|
if (z2) {
|
|
obj2 = next;
|
|
break;
|
|
}
|
|
}
|
|
Throwable th4 = (Throwable) obj2;
|
|
if (th4 != null) {
|
|
return th4;
|
|
}
|
|
}
|
|
return th2;
|
|
} else if (bVar.d()) {
|
|
return new JobCancellationException(q(), null, this);
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@Override // s.a.m1
|
|
public CancellationException z() {
|
|
Throwable th;
|
|
Object F = F();
|
|
CancellationException cancellationException = null;
|
|
if (F instanceof b) {
|
|
th = (Throwable) ((b) F)._rootCause;
|
|
} else if (F instanceof u) {
|
|
th = ((u) F).b;
|
|
} else if (!(F instanceof w0)) {
|
|
th = null;
|
|
} else {
|
|
throw new IllegalStateException(c.d.b.a.a.t("Cannot be cancelling child in this state: ", F).toString());
|
|
}
|
|
if (th instanceof CancellationException) {
|
|
cancellationException = th;
|
|
}
|
|
CancellationException cancellationException2 = cancellationException;
|
|
if (cancellationException2 != null) {
|
|
return cancellationException2;
|
|
}
|
|
StringBuilder L = c.d.b.a.a.L("Parent job is ");
|
|
L.append(T(F));
|
|
return new JobCancellationException(L.toString(), th, this);
|
|
}
|
|
}
|