what-the-bank/sources/o/fYE.java

179 lines
5.1 KiB
Java

package o;
import java.util.Objects;
import java.util.concurrent.PriorityBlockingQueue;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import o.AbstractC13173fSu;
/* loaded from: classes.dex */
public final class fYE extends AbstractC13173fSu {
private static final fYE b = new fYE();
@Override // o.AbstractC13173fSu
public final AbstractC13173fSu.Sts c() {
return new HBt();
}
fYE() {
}
@Override // o.AbstractC13173fSu
public final fSJ d(Runnable runnable, long j, TimeUnit timeUnit) {
try {
timeUnit.sleep(j);
Objects.requireNonNull(runnable, "run is null");
runnable.run();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
C13418fZu.c(e);
}
return EnumC13195fTi.INSTANCE;
}
/* loaded from: classes6.dex */
static final class HBt extends AbstractC13173fSu.Sts {
volatile boolean a;
final PriorityBlockingQueue<IeS> b = new PriorityBlockingQueue<>();
private final AtomicInteger e = new AtomicInteger();
private AtomicInteger c = new AtomicInteger();
HBt() {
}
@Override // o.AbstractC13173fSu.Sts
public final fSJ c(Runnable runnable) {
return e(runnable, AbstractC13173fSu.a(TimeUnit.MILLISECONDS));
}
@Override // o.AbstractC13173fSu.Sts
public final fSJ a(Runnable runnable, long j, TimeUnit timeUnit) {
long a = AbstractC13173fSu.a(TimeUnit.MILLISECONDS) + timeUnit.toMillis(j);
return e(new RVV(runnable, this, a), a);
}
private fSJ e(Runnable runnable, long j) {
if (this.a) {
return EnumC13195fTi.INSTANCE;
}
IeS ieS = new IeS(runnable, Long.valueOf(j), this.c.incrementAndGet());
this.b.add(ieS);
if (this.e.getAndIncrement() == 0) {
int i = 1;
while (!this.a) {
IeS poll = this.b.poll();
if (poll != null) {
if (!poll.d) {
poll.a.run();
}
} else {
i = this.e.addAndGet(-i);
if (i == 0) {
return EnumC13195fTi.INSTANCE;
}
}
}
this.b.clear();
return EnumC13195fTi.INSTANCE;
}
return fSJ.b(new RVV(this, ieS));
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public final class RVV implements Runnable {
private IeS d;
private HBt e;
RVV(HBt hBt, IeS ieS) {
this.e = hBt;
this.d = ieS;
}
@Override // java.lang.Runnable
public final void run() {
this.d.d = true;
this.e.b.remove(this.d);
}
}
@Override // o.fSJ
public final boolean isDisposed() {
return this.a;
}
@Override // o.fSJ
public final void dispose() {
this.a = true;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes6.dex */
public static final class IeS implements Comparable<IeS> {
final Runnable a;
private int b;
private long c;
volatile boolean d;
@Override // java.lang.Comparable
public final /* synthetic */ int compareTo(IeS ieS) {
IeS ieS2 = ieS;
int compare = Long.compare(this.c, ieS2.c);
return compare == 0 ? Integer.compare(this.b, ieS2.b) : compare;
}
IeS(Runnable runnable, Long l, int i) {
this.a = runnable;
this.c = l.longValue();
this.b = i;
}
}
/* loaded from: classes6.dex */
static final class RVV implements Runnable {
private final HBt a;
private final Runnable b;
private final long e;
RVV(Runnable runnable, HBt hBt, long j) {
this.b = runnable;
this.a = hBt;
this.e = j;
}
@Override // java.lang.Runnable
public final void run() {
if (this.a.a) {
return;
}
long c = HBt.c(TimeUnit.MILLISECONDS);
long j = this.e;
if (j > c) {
try {
Thread.sleep(j - c);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
C13418fZu.c(e);
return;
}
}
if (this.a.a) {
return;
}
this.b.run();
}
}
@Override // o.AbstractC13173fSu
public final fSJ a(Runnable runnable) {
Objects.requireNonNull(runnable, "run is null");
runnable.run();
return EnumC13195fTi.INSTANCE;
}
public static fYE d() {
return b;
}
}