package kotlinx.coroutines;

import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;

/* JADX INFO: loaded from: classes.dex */
public abstract class b1 extends kotlinx.coroutines.internal.i implements j0, v0, sd.l {

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public g1 f29293d;

    @Override // kotlinx.coroutines.v0
    public final j1 d() {
        return null;
    }

    @Override // kotlinx.coroutines.j0
    public final void dispose() {
        AtomicReferenceFieldUpdater atomicReferenceFieldUpdater;
        AtomicReferenceFieldUpdater atomicReferenceFieldUpdater2;
        g1 g1VarJ = j();
        while (true) {
            Object objG = g1VarJ.G();
            if (objG instanceof b1) {
                if (objG != this) {
                    return;
                }
                l0 l0Var = y.f29591r;
                do {
                    atomicReferenceFieldUpdater2 = g1.f29433a;
                    if (atomicReferenceFieldUpdater2.compareAndSet(g1VarJ, objG, l0Var)) {
                        return;
                    }
                } while (atomicReferenceFieldUpdater2.get(g1VarJ) == objG);
            } else {
                if (!(objG instanceof v0) || ((v0) objG).d() == null) {
                    return;
                }
                while (true) {
                    Object objG2 = g();
                    if (objG2 instanceof kotlinx.coroutines.internal.p) {
                        kotlinx.coroutines.internal.i iVar = ((kotlinx.coroutines.internal.p) objG2).f29484a;
                        return;
                    }
                    if (objG2 == this) {
                        return;
                    }
                    nb.g.g(objG2, "null cannot be cast to non-null type kotlinx.coroutines.internal.LockFreeLinkedListNode{ kotlinx.coroutines.internal.LockFreeLinkedListKt.Node }");
                    kotlinx.coroutines.internal.i iVar2 = (kotlinx.coroutines.internal.i) objG2;
                    AtomicReferenceFieldUpdater atomicReferenceFieldUpdater3 = kotlinx.coroutines.internal.i.f29473c;
                    kotlinx.coroutines.internal.p pVar = (kotlinx.coroutines.internal.p) atomicReferenceFieldUpdater3.get(iVar2);
                    if (pVar == null) {
                        pVar = new kotlinx.coroutines.internal.p(iVar2);
                        atomicReferenceFieldUpdater3.set(iVar2, pVar);
                    }
                    do {
                        atomicReferenceFieldUpdater = kotlinx.coroutines.internal.i.f29471a;
                        if (atomicReferenceFieldUpdater.compareAndSet(this, objG2, pVar)) {
                            iVar2.e();
                            return;
                        }
                    } while (atomicReferenceFieldUpdater.get(this) == objG2);
                }
            }
        }
    }

    public y0 getParent() {
        return j();
    }

    @Override // kotlinx.coroutines.v0
    public final boolean isActive() {
        return true;
    }

    public final g1 j() {
        g1 g1Var = this.f29293d;
        if (g1Var != null) {
            return g1Var;
        }
        nb.g.U("job");
        throw null;
    }

    public abstract void k(Throwable th);

    @Override // kotlinx.coroutines.internal.i
    public final String toString() {
        return getClass().getSimpleName() + '@' + y.z(this) + "[job@" + y.z(j()) + ']';
    }
}
