package kotlinx.coroutines;

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

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

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

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

    public static /* synthetic */ void N(f1 f1Var, boolean z, int i2, Object obj) {
        if (obj != null) {
            throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: decrementUseCount");
        }
        if ((i2 & 1) != 0) {
            z = false;
        }
        f1Var.K(z);
    }

    private final long P(boolean z) {
        return z ? 4294967296L : 1L;
    }

    public static /* synthetic */ void T(f1 f1Var, boolean z, int i2, Object obj) {
        if (obj != null) {
            throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: incrementUseCount");
        }
        if ((i2 & 1) != 0) {
            z = false;
        }
        f1Var.S(z);
    }

    public final void K(boolean z) {
        long jP = this.f1075f - P(z);
        this.f1075f = jP;
        if (jP > 0) {
            return;
        }
        if (r0.a()) {
            if (!(this.f1075f == 0)) {
                throw new AssertionError();
            }
        }
        if (this.f1076g) {
            shutdown();
        }
    }

    public final void Q(z0<?> z0Var) {
        kotlinx.coroutines.o2.a<z0<?>> aVar = this.f1077h;
        if (aVar == null) {
            aVar = new kotlinx.coroutines.o2.a<>();
            this.f1077h = aVar;
        }
        aVar.a(z0Var);
    }

    protected long R() {
        kotlinx.coroutines.o2.a<z0<?>> aVar = this.f1077h;
        return (aVar == null || aVar.c()) ? Long.MAX_VALUE : 0L;
    }

    public final void S(boolean z) {
        this.f1075f += P(z);
        if (z) {
            return;
        }
        this.f1076g = true;
    }

    public final boolean U() {
        return this.f1075f >= P(true);
    }

    public final boolean V() {
        kotlinx.coroutines.o2.a<z0<?>> aVar = this.f1077h;
        if (aVar == null) {
            return true;
        }
        return aVar.c();
    }

    public long W() {
        return !X() ? Long.MAX_VALUE : 0L;
    }

    public final boolean X() {
        z0<?> z0VarD;
        kotlinx.coroutines.o2.a<z0<?>> aVar = this.f1077h;
        if (aVar == null || (z0VarD = aVar.d()) == null) {
            return false;
        }
        z0VarD.run();
        return true;
    }

    public boolean a0() {
        return false;
    }

    protected void shutdown() {
    }
}
