package o;

import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* renamed from: o.hL, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public final class C1377hL extends AbstractC2842wn implements InterfaceC0405Pq {
    public static final /* synthetic */ AtomicIntegerFieldUpdater r = AtomicIntegerFieldUpdater.newUpdater(C1377hL.class, "runningWorkers$volatile");
    public final /* synthetic */ InterfaceC0405Pq m;
    public final AbstractC2842wn n;

    /* renamed from: o, reason: collision with root package name */
    public final int f560o;
    public final C2802wM p;
    public final Object q;
    private volatile /* synthetic */ int runningWorkers$volatile;

    /* JADX WARN: Multi-variable type inference failed */
    public C1377hL(AbstractC2842wn abstractC2842wn, int i) {
        InterfaceC0405Pq interfaceC0405Pq = abstractC2842wn instanceof InterfaceC0405Pq ? (InterfaceC0405Pq) abstractC2842wn : null;
        this.m = interfaceC0405Pq == null ? AbstractC0560Vp.a : interfaceC0405Pq;
        this.n = abstractC2842wn;
        this.f560o = i;
        this.p = new C2802wM();
        this.q = new Object();
    }

    @Override // o.InterfaceC0405Pq
    public final void G(long j, C2448sg c2448sg) {
        this.m.G(j, c2448sg);
    }

    @Override // o.AbstractC2842wn
    public final void T(InterfaceC2747vn interfaceC2747vn, Runnable runnable) {
        Runnable runnableX;
        this.p.a(runnable);
        if (r.get(this) >= this.f560o || !Y() || (runnableX = X()) == null) {
            return;
        }
        this.n.T(this, new RunnableC0890cD(10, this, runnableX, false));
    }

    @Override // o.AbstractC2842wn
    public final void U(InterfaceC2747vn interfaceC2747vn, Runnable runnable) {
        Runnable runnableX;
        this.p.a(runnable);
        if (r.get(this) >= this.f560o || !Y() || (runnableX = X()) == null) {
            return;
        }
        this.n.U(this, new RunnableC0890cD(10, this, runnableX, false));
    }

    public final Runnable X() {
        while (true) {
            Runnable runnable = (Runnable) this.p.d();
            if (runnable != null) {
                return runnable;
            }
            synchronized (this.q) {
                AtomicIntegerFieldUpdater atomicIntegerFieldUpdater = r;
                atomicIntegerFieldUpdater.decrementAndGet(this);
                if (this.p.c() == 0) {
                    return null;
                }
                atomicIntegerFieldUpdater.incrementAndGet(this);
            }
        }
    }

    public final boolean Y() {
        synchronized (this.q) {
            AtomicIntegerFieldUpdater atomicIntegerFieldUpdater = r;
            if (atomicIntegerFieldUpdater.get(this) >= this.f560o) {
                return false;
            }
            atomicIntegerFieldUpdater.incrementAndGet(this);
            return true;
        }
    }

    @Override // o.AbstractC2842wn
    public final String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(this.n);
        sb.append(".limitedParallelism(");
        return AbstractC2462sn.m(sb, this.f560o, ')');
    }

    @Override // o.InterfaceC0405Pq
    public final InterfaceC2567ts u(long j, Ef0 ef0, InterfaceC2747vn interfaceC2747vn) {
        return this.m.u(j, ef0, interfaceC2747vn);
    }
}
