package defpackage;

import androidx.media3.container.NalUnitUtil;
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
import kotlin.Metadata;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\u0010\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0000\b&\u0018\u0000*\b\b\u0000\u0010\u0002*\u00020\u00012\b\u0012\u0004\u0012\u00028\u00000\u0003¨\u0006\u0004"}, d2 = {"Leu8;", "", "T", "Lqs6;", "ktor-io"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
@vx8
public abstract class eu8<T> implements qs6<T> {
    public static final /* synthetic */ AtomicIntegerFieldUpdater a;

    @kp6
    private volatile /* synthetic */ int borrowed;

    @kp6
    private volatile /* synthetic */ int disposed;

    @kp6
    private volatile /* synthetic */ Object instance;

    static {
        AtomicIntegerFieldUpdater.newUpdater(eu8.class, "borrowed");
        a = AtomicIntegerFieldUpdater.newUpdater(eu8.class, "disposed");
    }

    public abstract void a();

    @Override // defpackage.qs6
    public final void cd(Object obj) {
        cr4.g(obj, "instance");
        if (this.instance != obj) {
            if (this.instance == null && this.borrowed != 0) {
                throw new IllegalStateException("Already recycled or an irrelevant instance tried to be recycled");
            }
            throw new IllegalStateException("Unable to recycle irrelevant instance");
        }
        this.instance = null;
        if (!a.compareAndSet(this, 0, 1)) {
            throw new IllegalStateException("An instance is already disposed");
        }
        a();
    }

    @Override // java.lang.AutoCloseable
    public final void close() {
        if (!a.compareAndSet(this, 0, 1) || this.instance == null) {
            return;
        }
        this.instance = null;
        a();
    }
}
