package o;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class Jh0 extends M40 {
    public final ThreadLocal p;
    private volatile boolean threadLocalIsSet;

    /* JADX WARN: Illegal instructions before constructor call */
    public Jh0(InterfaceC0220Im interfaceC0220Im, InterfaceC2747vn interfaceC2747vn) {
        C2828wg c2828wg = C2828wg.n;
        super(interfaceC0220Im, interfaceC2747vn.m(c2828wg) == null ? interfaceC2747vn.M(c2828wg) : interfaceC2747vn);
        this.p = new ThreadLocal();
        if (interfaceC0220Im.h().m(C0669Zu.D) instanceof AbstractC2842wn) {
            return;
        }
        Object objI = AbstractC1155f00.I(interfaceC2747vn, null);
        AbstractC1155f00.C(interfaceC2747vn, objI);
        o0(interfaceC2747vn, objI);
    }

    public final boolean n0() {
        boolean z = this.threadLocalIsSet && this.p.get() == null;
        this.p.remove();
        return !z;
    }

    public final void o0(InterfaceC2747vn interfaceC2747vn, Object obj) {
        this.threadLocalIsSet = true;
        this.p.set(new C3001yV(interfaceC2747vn, obj));
    }

    @Override // o.M40, o.C1375hJ
    public final void x(Object obj) {
        if (this.threadLocalIsSet) {
            C3001yV c3001yV = (C3001yV) this.p.get();
            if (c3001yV != null) {
                AbstractC1155f00.C((InterfaceC2747vn) c3001yV.l, c3001yV.m);
            }
            this.p.remove();
        }
        Object objB = IJ.B(obj);
        InterfaceC0220Im interfaceC0220Im = this.f225o;
        InterfaceC2747vn interfaceC2747vnH = interfaceC0220Im.h();
        Object objI = AbstractC1155f00.I(interfaceC2747vnH, null);
        Jh0 jh0G = objI != AbstractC1155f00.g ? C2887xC.G(interfaceC0220Im, interfaceC2747vnH, objI) : null;
        try {
            this.f225o.resumeWith(objB);
            if (jh0G == null || jh0G.n0()) {
                AbstractC1155f00.C(interfaceC2747vnH, objI);
            }
        } catch (Throwable th) {
            if (jh0G == null || jh0G.n0()) {
                AbstractC1155f00.C(interfaceC2747vnH, objI);
            }
            throw th;
        }
    }
}
