package o; import com.google.common.util.concurrent.Striped$SmallLazyStriped$$ExternalSyntheticBackportWithForwarding0; import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; import java.util.concurrent.atomic.AtomicReferenceArray; import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; /* renamed from: o.ghL, reason: case insensitive filesystem */ /* loaded from: classes.dex */ public final class C15105ghL { static final AtomicReferenceFieldUpdater e = AtomicReferenceFieldUpdater.newUpdater(C15105ghL.class, Object.class, "lastScheduledTask"); private static final AtomicIntegerFieldUpdater a = AtomicIntegerFieldUpdater.newUpdater(C15105ghL.class, "producerIndex"); private static final AtomicIntegerFieldUpdater b = AtomicIntegerFieldUpdater.newUpdater(C15105ghL.class, "consumerIndex"); private static final AtomicIntegerFieldUpdater c = AtomicIntegerFieldUpdater.newUpdater(C15105ghL.class, "blockingTasksInBuffer"); private final AtomicReferenceArray d = new AtomicReferenceArray<>(128); volatile Object lastScheduledTask = null; volatile int producerIndex = 0; volatile int consumerIndex = 0; private volatile int blockingTasksInBuffer = 0; public final ghE d(ghE ghe, boolean z) { if (z) { return d(ghe); } ghE ghe2 = (ghE) e.getAndSet(this, ghe); if (ghe2 == null) { return null; } return d(ghe2); } public final long c(C15105ghL c15105ghL) { C15045gfe.b(); ghE b2 = c15105ghL.b(); if (b2 == null) { return c(c15105ghL, false); } d(b2, false); C15045gfe.b(); return -1L; } public final long e(C15105ghL c15105ghL) { C15045gfe.b(); int i = c15105ghL.producerIndex; AtomicReferenceArray atomicReferenceArray = c15105ghL.d; for (int i2 = c15105ghL.consumerIndex; i2 != i; i2++) { int i3 = i2 & 127; if (c15105ghL.blockingTasksInBuffer == 0) { break; } ghE ghe = atomicReferenceArray.get(i3); if (ghe != null && ghe.j.c() == 1 && Striped$SmallLazyStriped$$ExternalSyntheticBackportWithForwarding0.m(atomicReferenceArray, i3, ghe, null)) { c.decrementAndGet(c15105ghL); d(ghe, false); return -1L; } } return c(c15105ghL, true); } private final long c(C15105ghL c15105ghL, boolean z) { while (true) { ghE ghe = (ghE) c15105ghL.lastScheduledTask; if (ghe == null) { return -2L; } if (z && ghe.j.c() != 1) { return -2L; } long d = ghB.i.d() - ghe.g; if (d < ghB.j) { return ghB.j - d; } AtomicReferenceFieldUpdater atomicReferenceFieldUpdater = e; while (!atomicReferenceFieldUpdater.compareAndSet(c15105ghL, ghe, null)) { if (atomicReferenceFieldUpdater.get(c15105ghL) != ghe) { break; } } d(ghe, false); return -1L; } } /* JADX INFO: Access modifiers changed from: package-private */ public final ghE b() { ghE andSet; while (true) { int i = this.consumerIndex; if (i - this.producerIndex == 0) { return null; } if (b.compareAndSet(this, i, i + 1) && (andSet = this.d.getAndSet(i & 127, null)) != null) { if (andSet != null && andSet.j.c() == 1) { c.decrementAndGet(this); C15045gfe.b(); } return andSet; } } } private final ghE d(ghE ghe) { if (ghe.j.c() == 1) { c.incrementAndGet(this); } if (this.producerIndex - this.consumerIndex == 127) { return ghe; } int i = this.producerIndex & 127; while (this.d.get(i) != null) { Thread.yield(); } this.d.lazySet(i, ghe); a.incrementAndGet(this); return null; } }