package b7;

import Z6.AbstractC0359a;
import Z6.AbstractC0385z;
import Z6.F;
import Z6.e0;
import d3.V0;
import java.lang.reflect.InvocationTargetException;
import java.util.concurrent.CancellationException;
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;

/* JADX INFO: loaded from: classes.dex */
public final class t extends AbstractC0359a implements u, InterfaceC0560j {

    /* JADX INFO: renamed from: t, reason: collision with root package name */
    public final C0556f f9273t;

    public t(E6.i iVar, C0556f c0556f) {
        super(iVar, true);
        this.f9273t = c0556f;
    }

    @Override // Z6.k0, Z6.d0
    public final void b(CancellationException cancellationException) throws IllegalAccessException, InvocationTargetException {
        if (isCancelled()) {
            return;
        }
        if (cancellationException == null) {
            cancellationException = new e0(x(), null, this);
        }
        v(cancellationException);
    }

    @Override // b7.w
    public final Object e(Object obj) {
        return this.f9273t.e(obj);
    }

    @Override // Z6.AbstractC0359a
    public final void g0(Throwable th, boolean z8) throws IllegalAccessException, InvocationTargetException {
        if (this.f9273t.g(th, false) || z8) {
            return;
        }
        AbstractC0385z.p(this.f7495s, th);
    }

    @Override // Z6.AbstractC0359a
    public final void h0(Object obj) {
        this.f9273t.g(null, false);
    }

    public final void j0(s sVar) throws IllegalAccessException, F, InvocationTargetException {
        AtomicReferenceFieldUpdater atomicReferenceFieldUpdater;
        C0556f c0556f = this.f9273t;
        c0556f.getClass();
        do {
            atomicReferenceFieldUpdater = C0556f.f9238z;
            if (atomicReferenceFieldUpdater.compareAndSet(c0556f, null, sVar)) {
                return;
            }
        } while (atomicReferenceFieldUpdater.get(c0556f) == null);
        while (true) {
            Object obj = atomicReferenceFieldUpdater.get(c0556f);
            B3.f fVar = AbstractC0558h.f9256q;
            if (obj != fVar) {
                if (obj == AbstractC0558h.f9257r) {
                    throw new IllegalStateException("Another handler was already registered and successfully invoked");
                }
                throw new IllegalStateException(("Another handler is already registered: " + obj).toString());
            }
            B3.f fVar2 = AbstractC0558h.f9257r;
            while (!atomicReferenceFieldUpdater.compareAndSet(c0556f, fVar, fVar2)) {
                if (atomicReferenceFieldUpdater.get(c0556f) != fVar) {
                    break;
                }
            }
            sVar.b(c0556f.n());
            return;
        }
    }

    @Override // b7.w
    public final Object k(E6.d dVar, Object obj) {
        return this.f9273t.k(dVar, obj);
    }

    @Override // b7.v
    public final V0 l() {
        return this.f9273t.l();
    }

    @Override // Z6.k0
    public final void v(CancellationException cancellationException) throws IllegalAccessException, InvocationTargetException {
        this.f9273t.g(cancellationException, true);
        t(cancellationException);
    }
}
