1079 lines
36 KiB
Java
1079 lines
36 KiB
Java
package s.a;
|
|
|
|
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.i;
|
|
import s.a.a.j;
|
|
import s.a.a.k;
|
|
import s.a.a.p;
|
|
import s.a.a.t;
|
|
/* compiled from: JobSupport.kt */
|
|
public class g1 implements Job, q, o1 {
|
|
public static final AtomicReferenceFieldUpdater i = AtomicReferenceFieldUpdater.newUpdater(g1.class, Object.class, "_state");
|
|
public volatile Object _parentHandle;
|
|
public volatile Object _state;
|
|
|
|
/* compiled from: JobSupport.kt */
|
|
public static final class a extends f1<Job> {
|
|
public final g1 m;
|
|
public final b n;
|
|
public final p o;
|
|
public final Object p;
|
|
|
|
public a(g1 g1Var, b bVar, p pVar, Object obj) {
|
|
super(pVar.m);
|
|
this.m = g1Var;
|
|
this.n = bVar;
|
|
this.o = pVar;
|
|
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.x
|
|
public void q(Throwable th) {
|
|
g1 g1Var = this.m;
|
|
b bVar = this.n;
|
|
p pVar = this.o;
|
|
Object obj = this.p;
|
|
p O = g1Var.O(pVar);
|
|
if (O == null || !g1Var.W(bVar, O, obj)) {
|
|
g1Var.m(g1Var.w(bVar, obj));
|
|
}
|
|
}
|
|
|
|
@Override // s.a.a.k
|
|
public String toString() {
|
|
StringBuilder K = c.d.b.a.a.K("ChildCompletion[");
|
|
K.append(this.o);
|
|
K.append(", ");
|
|
K.append(this.p);
|
|
K.append(']');
|
|
return K.toString();
|
|
}
|
|
}
|
|
|
|
/* compiled from: JobSupport.kt */
|
|
public static final class b implements y0 {
|
|
public volatile Object _exceptionsHolder = null;
|
|
public volatile int _isCompleting;
|
|
public volatile Object _rootCause;
|
|
public final l1 i;
|
|
|
|
public b(l1 l1Var, boolean z2, Throwable th) {
|
|
this.i = l1Var;
|
|
this._isCompleting = z2 ? 1 : 0;
|
|
this._rootCause = th;
|
|
}
|
|
|
|
@Override // s.a.y0
|
|
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.r("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 == h1.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.r("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 = h1.e;
|
|
return arrayList;
|
|
}
|
|
|
|
@Override // s.a.y0
|
|
public l1 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 K = c.d.b.a.a.K("Finishing[cancelling=");
|
|
K.append(d());
|
|
K.append(", completing=");
|
|
K.append((boolean) this._isCompleting);
|
|
K.append(", rootCause=");
|
|
K.append((Throwable) this._rootCause);
|
|
K.append(", exceptions=");
|
|
K.append(this._exceptionsHolder);
|
|
K.append(", list=");
|
|
K.append(this.i);
|
|
K.append(']');
|
|
return K.toString();
|
|
}
|
|
}
|
|
|
|
/* compiled from: LockFreeLinkedList.kt */
|
|
public static final class c extends k.a {
|
|
public final /* synthetic */ g1 d;
|
|
public final /* synthetic */ Object e;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public c(k kVar, k kVar2, g1 g1Var, Object obj) {
|
|
super(kVar2);
|
|
this.d = g1Var;
|
|
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(k kVar) {
|
|
if (this.d.F() == this.e) {
|
|
return null;
|
|
}
|
|
return j.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<d0.f0.k<? super q>, 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 d0.f0.k p$;
|
|
public final /* synthetic */ g1 this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public d(g1 g1Var, Continuation continuation) {
|
|
super(2, continuation);
|
|
this.this$0 = g1Var;
|
|
}
|
|
|
|
@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$ = (d0.f0.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(d0.f0.k<? super q> 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;
|
|
d0.f0.k kVar;
|
|
Object obj2;
|
|
i iVar;
|
|
i iVar2;
|
|
k kVar2;
|
|
Object coroutine_suspended = d0.w.g.c.getCOROUTINE_SUSPENDED();
|
|
int i = this.label;
|
|
if (i == 0) {
|
|
l.throwOnFailure(obj);
|
|
d0.f0.k kVar3 = this.p$;
|
|
Object F = this.this$0.F();
|
|
if (F instanceof p) {
|
|
q qVar = ((p) F).m;
|
|
this.L$0 = kVar3;
|
|
this.L$1 = F;
|
|
this.label = 1;
|
|
if (kVar3.yield(qVar, this) == coroutine_suspended) {
|
|
return coroutine_suspended;
|
|
}
|
|
} else if ((F instanceof y0) && (iVar2 = ((y0) F).getList()) != null) {
|
|
Object i2 = iVar2.i();
|
|
Objects.requireNonNull(i2, "null cannot be cast to non-null type kotlinx.coroutines.internal.Node /* = kotlinx.coroutines.internal.LockFreeLinkedListNode */");
|
|
kVar = kVar3;
|
|
obj2 = F;
|
|
kVar2 = (k) i2;
|
|
dVar = this;
|
|
iVar = iVar2;
|
|
}
|
|
return Unit.a;
|
|
} else if (i == 1) {
|
|
d0.f0.k kVar4 = (d0.f0.k) this.L$0;
|
|
l.throwOnFailure(obj);
|
|
return Unit.a;
|
|
} else if (i == 2) {
|
|
p pVar = (p) this.L$5;
|
|
kVar2 = (k) this.L$4;
|
|
iVar2 = (i) this.L$3;
|
|
iVar = (l1) this.L$2;
|
|
obj2 = this.L$1;
|
|
kVar = (d0.f0.k) this.L$0;
|
|
l.throwOnFailure(obj);
|
|
dVar = this;
|
|
kVar2 = kVar2.j();
|
|
} else {
|
|
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
|
|
}
|
|
if (!m.areEqual(kVar2, iVar2)) {
|
|
if (kVar2 instanceof p) {
|
|
p pVar2 = (p) kVar2;
|
|
q qVar2 = pVar2.m;
|
|
dVar.L$0 = kVar;
|
|
dVar.L$1 = obj2;
|
|
dVar.L$2 = iVar;
|
|
dVar.L$3 = iVar2;
|
|
dVar.L$4 = kVar2;
|
|
dVar.L$5 = pVar2;
|
|
dVar.label = 2;
|
|
if (kVar.yield(qVar2, dVar) == coroutine_suspended) {
|
|
return coroutine_suspended;
|
|
}
|
|
}
|
|
kVar2 = kVar2.j();
|
|
if (!m.areEqual(kVar2, iVar2)) {
|
|
}
|
|
}
|
|
return Unit.a;
|
|
}
|
|
}
|
|
|
|
public g1(boolean z2) {
|
|
this._state = z2 ? h1.g : h1.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 l1 E(y0 y0Var) {
|
|
l1 list = y0Var.getList();
|
|
if (list != null) {
|
|
return list;
|
|
}
|
|
if (y0Var instanceof o0) {
|
|
return new l1();
|
|
}
|
|
if (y0Var instanceof f1) {
|
|
S((f1) y0Var);
|
|
return null;
|
|
}
|
|
throw new IllegalStateException(("State should have list: " + y0Var).toString());
|
|
}
|
|
|
|
public final Object F() {
|
|
while (true) {
|
|
Object obj = this._state;
|
|
if (!(obj instanceof p)) {
|
|
return obj;
|
|
}
|
|
((p) obj).a(this);
|
|
}
|
|
}
|
|
|
|
@Override // kotlinx.coroutines.Job
|
|
public final o G(q qVar) {
|
|
l0 y2 = c.q.a.k.a.y(this, true, false, new p(this, qVar), 2, null);
|
|
Objects.requireNonNull(y2, "null cannot be cast to non-null type kotlinx.coroutines.ChildHandle");
|
|
return (o) y2;
|
|
}
|
|
|
|
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 = m1.i;
|
|
return;
|
|
}
|
|
job.start();
|
|
o G = job.G(this);
|
|
this._parentHandle = G;
|
|
if (!(F() instanceof y0)) {
|
|
G.dispose();
|
|
this._parentHandle = m1.i;
|
|
}
|
|
}
|
|
|
|
public boolean K() {
|
|
return false;
|
|
}
|
|
|
|
public final Object L(Object obj) {
|
|
Object V;
|
|
do {
|
|
V = V(F(), obj);
|
|
if (V == h1.a) {
|
|
String str = "Job " + this + " is already complete or completing, but is being completed with " + obj;
|
|
Throwable th = null;
|
|
if (!(obj instanceof v)) {
|
|
obj = null;
|
|
}
|
|
v vVar = (v) obj;
|
|
if (vVar != null) {
|
|
th = vVar.b;
|
|
}
|
|
throw new IllegalStateException(str, th);
|
|
}
|
|
} while (V == h1.f2896c);
|
|
return V;
|
|
}
|
|
|
|
public final f1<?> M(Function1<? super Throwable, Unit> function1, boolean z2) {
|
|
d1 d1Var = null;
|
|
if (z2) {
|
|
if (function1 instanceof d1) {
|
|
d1Var = function1;
|
|
}
|
|
d1 d1Var2 = d1Var;
|
|
return d1Var2 != null ? d1Var2 : new b1(this, function1);
|
|
}
|
|
if (function1 instanceof f1) {
|
|
d1Var = function1;
|
|
}
|
|
f1<?> f1Var = d1Var;
|
|
return f1Var != null ? f1Var : new c1(this, function1);
|
|
}
|
|
|
|
public String N() {
|
|
return getClass().getSimpleName();
|
|
}
|
|
|
|
public final p O(k kVar) {
|
|
while (kVar.m()) {
|
|
kVar = kVar.k();
|
|
}
|
|
while (true) {
|
|
kVar = kVar.j();
|
|
if (!kVar.m()) {
|
|
if (kVar instanceof p) {
|
|
return (p) kVar;
|
|
}
|
|
if (kVar instanceof l1) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public final void P(l1 l1Var, Throwable th) {
|
|
CompletionHandlerException completionHandlerException = null;
|
|
Object i2 = l1Var.i();
|
|
Objects.requireNonNull(i2, "null cannot be cast to non-null type kotlinx.coroutines.internal.Node /* = kotlinx.coroutines.internal.LockFreeLinkedListNode */");
|
|
for (k kVar = (k) i2; !m.areEqual(kVar, l1Var); kVar = kVar.j()) {
|
|
if (kVar instanceof d1) {
|
|
f1 f1Var = (f1) kVar;
|
|
try {
|
|
f1Var.q(th);
|
|
} catch (Throwable th2) {
|
|
if (completionHandlerException != null) {
|
|
d0.b.addSuppressed(completionHandlerException, th2);
|
|
} else {
|
|
completionHandlerException = new CompletionHandlerException("Exception in completion handler " + f1Var + " for " + this, th2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (completionHandlerException != null) {
|
|
I(completionHandlerException);
|
|
}
|
|
o(th);
|
|
}
|
|
|
|
public void Q(Object obj) {
|
|
}
|
|
|
|
public void R() {
|
|
}
|
|
|
|
public final void S(f1<?> f1Var) {
|
|
l1 l1Var = new l1();
|
|
k.j.lazySet(l1Var, f1Var);
|
|
k.i.lazySet(l1Var, f1Var);
|
|
while (true) {
|
|
if (f1Var.i() == f1Var) {
|
|
if (k.i.compareAndSet(f1Var, f1Var, l1Var)) {
|
|
l1Var.g(f1Var);
|
|
break;
|
|
}
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
i.compareAndSet(this, f1Var, f1Var.j());
|
|
}
|
|
|
|
public final String T(Object obj) {
|
|
if (!(obj instanceof b)) {
|
|
return obj instanceof y0 ? ((y0) obj).a() ? "Active" : "New" : obj instanceof v ? "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 y0)) {
|
|
return h1.a;
|
|
}
|
|
boolean z2 = true;
|
|
if (((obj instanceof o0) || (obj instanceof f1)) && !(obj instanceof p) && !(obj2 instanceof v)) {
|
|
y0 y0Var = (y0) obj;
|
|
if (!i.compareAndSet(this, y0Var, obj2 instanceof y0 ? new z0((y0) obj2) : obj2)) {
|
|
z2 = false;
|
|
} else {
|
|
Q(obj2);
|
|
u(y0Var, obj2);
|
|
}
|
|
return z2 ? obj2 : h1.f2896c;
|
|
}
|
|
y0 y0Var2 = (y0) obj;
|
|
l1 E = E(y0Var2);
|
|
if (E == null) {
|
|
return h1.f2896c;
|
|
}
|
|
p pVar = null;
|
|
b bVar = (b) (!(y0Var2 instanceof b) ? null : y0Var2);
|
|
if (bVar == null) {
|
|
bVar = new b(E, false, null);
|
|
}
|
|
synchronized (bVar) {
|
|
if (bVar._isCompleting != 0) {
|
|
return h1.a;
|
|
}
|
|
bVar._isCompleting = 1;
|
|
if (bVar == y0Var2 || i.compareAndSet(this, y0Var2, bVar)) {
|
|
boolean d2 = bVar.d();
|
|
v vVar = (v) (!(obj2 instanceof v) ? null : obj2);
|
|
if (vVar != null) {
|
|
bVar.b(vVar.b);
|
|
}
|
|
th = (Throwable) bVar._rootCause;
|
|
if (!(true ^ d2)) {
|
|
th = null;
|
|
}
|
|
} else {
|
|
return h1.f2896c;
|
|
}
|
|
}
|
|
if (th != null) {
|
|
P(E, th);
|
|
}
|
|
p pVar2 = (p) (!(y0Var2 instanceof p) ? null : y0Var2);
|
|
if (pVar2 != null) {
|
|
pVar = pVar2;
|
|
} else {
|
|
l1 list = y0Var2.getList();
|
|
if (list != null) {
|
|
pVar = O(list);
|
|
}
|
|
}
|
|
return (pVar == null || !W(bVar, pVar, obj2)) ? w(bVar, obj2) : h1.b;
|
|
}
|
|
|
|
public final boolean W(b bVar, p pVar, Object obj) {
|
|
while (c.q.a.k.a.y(pVar.m, false, false, new a(this, bVar, pVar, obj), 1, null) == m1.i) {
|
|
pVar = O(pVar);
|
|
if (pVar == null) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override // kotlinx.coroutines.Job
|
|
public boolean a() {
|
|
Object F = F();
|
|
return (F instanceof y0) && ((y0) 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 l0 f(boolean z2, boolean z3, Function1<? super Throwable, Unit> function1) {
|
|
Throwable th;
|
|
Throwable th2 = null;
|
|
f1<?> f1Var = null;
|
|
while (true) {
|
|
Object F = F();
|
|
if (F instanceof o0) {
|
|
o0 o0Var = (o0) F;
|
|
if (o0Var.i) {
|
|
if (f1Var == null) {
|
|
f1Var = M(function1, z2);
|
|
}
|
|
if (i.compareAndSet(this, F, f1Var)) {
|
|
return f1Var;
|
|
}
|
|
} else {
|
|
l1 l1Var = new l1();
|
|
if (!o0Var.i) {
|
|
l1Var = new x0(l1Var);
|
|
}
|
|
i.compareAndSet(this, o0Var, l1Var);
|
|
}
|
|
} else if (F instanceof y0) {
|
|
l1 list = ((y0) F).getList();
|
|
if (list == null) {
|
|
Objects.requireNonNull(F, "null cannot be cast to non-null type kotlinx.coroutines.JobNode<*>");
|
|
S((f1) F);
|
|
} else {
|
|
l0 l0Var = m1.i;
|
|
if (!z2 || !(F instanceof b)) {
|
|
th = null;
|
|
} else {
|
|
synchronized (F) {
|
|
th = (Throwable) ((b) F)._rootCause;
|
|
if (th == null || ((function1 instanceof p) && ((b) F)._isCompleting == 0)) {
|
|
if (f1Var == null) {
|
|
f1Var = M(function1, z2);
|
|
}
|
|
if (l(F, list, f1Var)) {
|
|
if (th == null) {
|
|
return f1Var;
|
|
}
|
|
l0Var = f1Var;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (th != null) {
|
|
if (z3) {
|
|
function1.invoke(th);
|
|
}
|
|
return l0Var;
|
|
}
|
|
if (f1Var == null) {
|
|
f1Var = M(function1, z2);
|
|
}
|
|
if (l(F, list, f1Var)) {
|
|
return f1Var;
|
|
}
|
|
}
|
|
} else {
|
|
if (z3) {
|
|
if (!(F instanceof v)) {
|
|
F = null;
|
|
}
|
|
v vVar = (v) F;
|
|
if (vVar != null) {
|
|
th2 = vVar.b;
|
|
}
|
|
function1.invoke(th2);
|
|
}
|
|
return m1.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, l1 l1Var, f1<?> f1Var) {
|
|
int p;
|
|
c cVar = new c(f1Var, f1Var, this, obj);
|
|
do {
|
|
p = l1Var.k().p(f1Var, l1Var, 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.h1.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) {
|
|
t tVar;
|
|
boolean z2;
|
|
t tVar2 = h1.a;
|
|
if (D()) {
|
|
while (true) {
|
|
Object F = F();
|
|
if ((F instanceof y0) && (!(F instanceof b) || ((b) F)._isCompleting == 0)) {
|
|
tVar2 = V(F, new v(v(obj), false, 2));
|
|
if (tVar2 != h1.f2896c) {
|
|
break;
|
|
}
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
if (tVar2 == h1.b) {
|
|
return true;
|
|
}
|
|
}
|
|
if (tVar2 == h1.a) {
|
|
Throwable th = null;
|
|
Throwable th2 = null;
|
|
while (true) {
|
|
Object F2 = F();
|
|
if (!(F2 instanceof b)) {
|
|
if (!(F2 instanceof y0)) {
|
|
tVar = h1.d;
|
|
break;
|
|
}
|
|
if (th2 == null) {
|
|
th2 = v(obj);
|
|
}
|
|
y0 y0Var = (y0) F2;
|
|
if (y0Var.a()) {
|
|
l1 E = E(y0Var);
|
|
if (E != null) {
|
|
if (i.compareAndSet(this, y0Var, new b(E, false, th2))) {
|
|
P(E, th2);
|
|
z2 = true;
|
|
if (!z2) {
|
|
tVar = h1.a;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
z2 = false;
|
|
if (!z2) {
|
|
}
|
|
} else {
|
|
Object V = V(F2, new v(th2, false, 2));
|
|
if (V != h1.a) {
|
|
if (V != h1.f2896c) {
|
|
tVar2 = V;
|
|
break;
|
|
}
|
|
} else {
|
|
throw new IllegalStateException(c.d.b.a.a.r("Cannot happen in ", F2).toString());
|
|
}
|
|
}
|
|
} else {
|
|
synchronized (F2) {
|
|
if (((b) F2).e()) {
|
|
tVar = h1.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);
|
|
}
|
|
tVar = h1.a;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
tVar2 = tVar;
|
|
}
|
|
if (!(tVar2 == h1.a || tVar2 == h1.b)) {
|
|
if (tVar2 == h1.d) {
|
|
return false;
|
|
}
|
|
m(tVar2);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public final boolean o(Throwable th) {
|
|
if (K()) {
|
|
return true;
|
|
}
|
|
boolean z2 = th instanceof CancellationException;
|
|
o oVar = (o) this._parentHandle;
|
|
return (oVar == null || oVar == m1.i) ? z2 : oVar.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 y0) {
|
|
throw new IllegalStateException(("Job is still new or active: " + this).toString());
|
|
} else if (F instanceof v) {
|
|
return U(((v) 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.q
|
|
public final void r(o1 o1Var) {
|
|
n(o1Var);
|
|
}
|
|
|
|
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 o0) {
|
|
if (!((o0) F).i) {
|
|
if (i.compareAndSet(this, F, h1.g)) {
|
|
R();
|
|
}
|
|
if (c2 == 0) {
|
|
return false;
|
|
}
|
|
}
|
|
c2 = 0;
|
|
if (c2 == 0) {
|
|
}
|
|
} else {
|
|
if (F instanceof x0) {
|
|
if (i.compareAndSet(this, F, ((x0) 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 l0 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.u(this));
|
|
return sb.toString();
|
|
}
|
|
|
|
public final void u(y0 y0Var, Object obj) {
|
|
o oVar = (o) this._parentHandle;
|
|
if (oVar != null) {
|
|
oVar.dispose();
|
|
this._parentHandle = m1.i;
|
|
}
|
|
CompletionHandlerException completionHandlerException = null;
|
|
if (!(obj instanceof v)) {
|
|
obj = null;
|
|
}
|
|
v vVar = (v) obj;
|
|
Throwable th = vVar != null ? vVar.b : null;
|
|
if (y0Var instanceof f1) {
|
|
try {
|
|
((f1) y0Var).q(th);
|
|
} catch (Throwable th2) {
|
|
I(new CompletionHandlerException("Exception in completion handler " + y0Var + " for " + this, th2));
|
|
}
|
|
} else {
|
|
l1 list = y0Var.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 (k kVar = (k) i2; !m.areEqual(kVar, list); kVar = kVar.j()) {
|
|
if (kVar instanceof f1) {
|
|
f1 f1Var = (f1) kVar;
|
|
try {
|
|
f1Var.q(th);
|
|
} catch (Throwable th3) {
|
|
if (completionHandlerException != null) {
|
|
d0.b.addSuppressed(completionHandlerException, th3);
|
|
} else {
|
|
completionHandlerException = new CompletionHandlerException("Exception in completion handler " + f1Var + " 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 ((o1) obj).z();
|
|
}
|
|
|
|
public final Object w(b bVar, Object obj) {
|
|
Throwable y2;
|
|
Throwable th = null;
|
|
v vVar = (v) (!(obj instanceof v) ? null : obj);
|
|
if (vVar != null) {
|
|
th = vVar.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 v(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");
|
|
v.a.compareAndSet((v) obj, 0, 1);
|
|
}
|
|
}
|
|
Q(obj);
|
|
i.compareAndSet(this, bVar, obj instanceof y0 ? new z0((y0) 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.o1
|
|
public CancellationException z() {
|
|
Throwable th;
|
|
Object F = F();
|
|
CancellationException cancellationException = null;
|
|
if (F instanceof b) {
|
|
th = (Throwable) ((b) F)._rootCause;
|
|
} else if (F instanceof v) {
|
|
th = ((v) F).b;
|
|
} else if (!(F instanceof y0)) {
|
|
th = null;
|
|
} else {
|
|
throw new IllegalStateException(c.d.b.a.a.r("Cannot be cancelling child in this state: ", F).toString());
|
|
}
|
|
if (th instanceof CancellationException) {
|
|
cancellationException = th;
|
|
}
|
|
CancellationException cancellationException2 = cancellationException;
|
|
if (cancellationException2 != null) {
|
|
return cancellationException2;
|
|
}
|
|
StringBuilder K = c.d.b.a.a.K("Parent job is ");
|
|
K.append(T(F));
|
|
return new JobCancellationException(K.toString(), th, this);
|
|
}
|
|
}
|