package d2;

/* JADX INFO: compiled from: EventLoop.common.kt */
/* JADX INFO: loaded from: classes.dex */
public abstract class o0 extends u {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    private long f4514f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    private boolean f4515g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    private kotlinx.coroutines.internal.a<j0<?>> f4516h;

    private final long n(boolean z2) {
        return z2 ? 4294967296L : 1L;
    }

    public static /* synthetic */ void s(o0 o0Var, boolean z2, int i3, Object obj) {
        if (obj != null) {
            throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: incrementUseCount");
        }
        if ((i3 & 1) != 0) {
            z2 = false;
        }
        o0Var.r(z2);
    }

    public final void j(boolean z2) {
        long jN = this.f4514f - n(z2);
        this.f4514f = jN;
        if (jN > 0) {
            return;
        }
        if (c0.a()) {
            if (!(this.f4514f == 0)) {
                throw new AssertionError();
            }
        }
        if (this.f4515g) {
            w();
        }
    }

    public final void p(j0<?> j0Var) {
        kotlinx.coroutines.internal.a<j0<?>> aVar = this.f4516h;
        if (aVar == null) {
            aVar = new kotlinx.coroutines.internal.a<>();
            this.f4516h = aVar;
        }
        aVar.a(j0Var);
    }

    protected long q() {
        kotlinx.coroutines.internal.a<j0<?>> aVar = this.f4516h;
        return (aVar == null || aVar.c()) ? Long.MAX_VALUE : 0L;
    }

    public final void r(boolean z2) {
        this.f4514f += n(z2);
        if (z2) {
            return;
        }
        this.f4515g = true;
    }

    public final boolean t() {
        return this.f4514f >= n(true);
    }

    public final boolean u() {
        kotlinx.coroutines.internal.a<j0<?>> aVar = this.f4516h;
        if (aVar == null) {
            return true;
        }
        return aVar.c();
    }

    public final boolean v() {
        j0<?> j0VarD;
        kotlinx.coroutines.internal.a<j0<?>> aVar = this.f4516h;
        if (aVar == null || (j0VarD = aVar.d()) == null) {
            return false;
        }
        j0VarD.run();
        return true;
    }

    public void w() {
    }
}
