package kotlinx.coroutines;

import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
import kotlin.coroutines.Continuation;

/* JADX INFO: loaded from: classes.dex */
public final class j extends z0 {

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public final h f29504e;

    public j(h hVar) {
        this.f29504e = hVar;
    }

    @Override // sd.l
    public final /* bridge */ /* synthetic */ Object invoke(Object obj) {
        k((Throwable) obj);
        return kd.e.f29109a;
    }

    @Override // kotlinx.coroutines.b1
    public final void k(Throwable th) {
        g1 g1VarJ = j();
        h hVar = this.f29504e;
        Throwable thR = hVar.r(g1VarJ);
        if (hVar.x()) {
            Continuation continuation = hVar.f29438d;
            nb.g.g(continuation, "null cannot be cast to non-null type kotlinx.coroutines.internal.DispatchedContinuation<*>");
            kotlinx.coroutines.internal.g gVar = (kotlinx.coroutines.internal.g) continuation;
            loop0: while (true) {
                AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = kotlinx.coroutines.internal.g.f29460h;
                Object obj = atomicReferenceFieldUpdater.get(gVar);
                la.e eVar = kotlinx.coroutines.internal.a.f29452d;
                if (!nb.g.c(obj, eVar)) {
                    if (!(obj instanceof Throwable)) {
                        while (!atomicReferenceFieldUpdater.compareAndSet(gVar, obj, null)) {
                            if (atomicReferenceFieldUpdater.get(gVar) != obj) {
                                break;
                            }
                        }
                        break loop0;
                    }
                    return;
                }
                while (!atomicReferenceFieldUpdater.compareAndSet(gVar, eVar, thR)) {
                    if (atomicReferenceFieldUpdater.get(gVar) != eVar) {
                        break;
                    }
                }
                return;
            }
        }
        hVar.o(thR);
        if (hVar.x()) {
            return;
        }
        hVar.p();
    }
}
