package o;

import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class P30 implements InterfaceC0220Im, InterfaceC0117En {
    public static final AtomicReferenceFieldUpdater m = AtomicReferenceFieldUpdater.newUpdater(P30.class, Object.class, "result");
    public final InterfaceC0220Im l;
    private volatile Object result;

    public P30(InterfaceC0220Im interfaceC0220Im) {
        EnumC0091Dn enumC0091Dn = EnumC0091Dn.l;
        this.l = interfaceC0220Im;
        this.result = enumC0091Dn;
    }

    @Override // o.InterfaceC0117En
    public final InterfaceC0117En e() {
        InterfaceC0220Im interfaceC0220Im = this.l;
        if (interfaceC0220Im instanceof InterfaceC0117En) {
            return (InterfaceC0117En) interfaceC0220Im;
        }
        return null;
    }

    @Override // o.InterfaceC0220Im
    public final InterfaceC2747vn h() {
        return this.l.h();
    }

    @Override // o.InterfaceC0220Im
    public final void resumeWith(Object obj) {
        while (true) {
            Object obj2 = this.result;
            EnumC0091Dn enumC0091Dn = EnumC0091Dn.m;
            if (obj2 == enumC0091Dn) {
                AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = m;
                while (!atomicReferenceFieldUpdater.compareAndSet(this, enumC0091Dn, obj)) {
                    if (atomicReferenceFieldUpdater.get(this) != enumC0091Dn) {
                        break;
                    }
                }
                return;
            }
            EnumC0091Dn enumC0091Dn2 = EnumC0091Dn.l;
            if (obj2 != enumC0091Dn2) {
                throw new IllegalStateException("Already resumed");
            }
            AtomicReferenceFieldUpdater atomicReferenceFieldUpdater2 = m;
            EnumC0091Dn enumC0091Dn3 = EnumC0091Dn.n;
            while (!atomicReferenceFieldUpdater2.compareAndSet(this, enumC0091Dn2, enumC0091Dn3)) {
                if (atomicReferenceFieldUpdater2.get(this) != enumC0091Dn2) {
                    break;
                }
            }
            this.l.resumeWith(obj);
            return;
        }
    }

    public final String toString() {
        return "SafeContinuation for " + this.l;
    }
}
