package V4;

import a5.AbstractC0988a;

/* JADX INFO: loaded from: classes3.dex */
public final class L0 extends a5.p {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final ThreadLocal f8256e;
    private volatile boolean threadLocalIsSet;

    /* JADX WARN: Illegal instructions before constructor call */
    public L0(A4.j jVar, A4.d dVar) {
        M0 m02 = M0.f8258a;
        super(jVar.get(m02) == null ? jVar.plus(m02) : jVar, dVar);
        this.f8256e = new ThreadLocal();
        if (dVar.getContext().get(A4.e.f99a) instanceof AbstractC0786y) {
            return;
        }
        Object objL = AbstractC0988a.l(jVar, null);
        AbstractC0988a.g(jVar, objL);
        Y(jVar, objL);
    }

    public final boolean X() {
        boolean z6 = this.threadLocalIsSet && this.f8256e.get() == null;
        this.f8256e.remove();
        return !z6;
    }

    public final void Y(A4.j jVar, Object obj) {
        this.threadLocalIsSet = true;
        this.f8256e.set(new w4.k(jVar, obj));
    }

    @Override // a5.p, V4.u0
    public final void j(Object obj) {
        if (this.threadLocalIsSet) {
            w4.k kVar = (w4.k) this.f8256e.get();
            if (kVar != null) {
                AbstractC0988a.g((A4.j) kVar.f25469a, kVar.f25470b);
            }
            this.f8256e.remove();
        }
        Object objA = E.A(obj);
        A4.d dVar = this.f10847d;
        A4.j context = dVar.getContext();
        Object objL = AbstractC0988a.l(context, null);
        L0 l0G = objL != AbstractC0988a.f10812d ? E.G(dVar, context, objL) : null;
        try {
            this.f10847d.resumeWith(objA);
            if (l0G == null || l0G.X()) {
                AbstractC0988a.g(context, objL);
            }
        } catch (Throwable th) {
            if (l0G == null || l0G.X()) {
                AbstractC0988a.g(context, objL);
            }
            throw th;
        }
    }
}
