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

225 lines
6.9 KiB
Java

package o;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
/* renamed from: o.fSu, reason: case insensitive filesystem */
/* loaded from: classes.dex */
public abstract class AbstractC13173fSu {
static final long a;
private static boolean e = Boolean.getBoolean("rx3.scheduler.use-nanotime");
public void b() {
}
public abstract Sts c();
static {
long nanos;
long longValue = Long.getLong("rx3.scheduler.drift-tolerance", 15L).longValue();
String property = System.getProperty("rx3.scheduler.drift-tolerance-unit", "minutes");
if ("seconds".equalsIgnoreCase(property)) {
nanos = TimeUnit.SECONDS.toNanos(longValue);
} else if ("milliseconds".equalsIgnoreCase(property)) {
nanos = TimeUnit.MILLISECONDS.toNanos(longValue);
} else {
nanos = TimeUnit.MINUTES.toNanos(longValue);
}
a = nanos;
}
public static long a(TimeUnit timeUnit) {
if (!e) {
return timeUnit.convert(System.currentTimeMillis(), TimeUnit.MILLISECONDS);
}
return timeUnit.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
}
public static long b(TimeUnit timeUnit) {
if (!e) {
return timeUnit.convert(System.currentTimeMillis(), TimeUnit.MILLISECONDS);
}
return timeUnit.convert(System.nanoTime(), TimeUnit.NANOSECONDS);
}
public fSJ a(Runnable runnable) {
return d(runnable, 0L, TimeUnit.NANOSECONDS);
}
public fSJ d(Runnable runnable, long j, TimeUnit timeUnit) {
Sts c = c();
Objects.requireNonNull(runnable, "run is null");
RVV rvv = new RVV(runnable, c);
c.a(rvv, j, timeUnit);
return rvv;
}
public fSJ d(Runnable runnable, long j, long j2, TimeUnit timeUnit) {
Sts c = c();
Objects.requireNonNull(runnable, "run is null");
LWm lWm = new LWm(runnable, c);
fSJ a2 = c.a(lWm, j, j2, timeUnit);
return a2 == EnumC13195fTi.INSTANCE ? a2 : lWm;
}
/* renamed from: o.fSu$Sts */
/* loaded from: classes.dex */
public static abstract class Sts implements fSJ {
public abstract fSJ a(Runnable runnable, long j, TimeUnit timeUnit);
public fSJ c(Runnable runnable) {
return a(runnable, 0L, TimeUnit.NANOSECONDS);
}
public final fSJ a(Runnable runnable, long j, long j2, TimeUnit timeUnit) {
C13197fTk c13197fTk = new C13197fTk();
C13197fTk c13197fTk2 = new C13197fTk(c13197fTk);
Objects.requireNonNull(runnable, "run is null");
long nanos = timeUnit.toNanos(j2);
long a = AbstractC13173fSu.a(TimeUnit.NANOSECONDS);
fSJ a2 = a(new RVV(this, a + timeUnit.toNanos(j), runnable, a, c13197fTk2, nanos), j, timeUnit);
if (a2 == EnumC13195fTi.INSTANCE) {
return a2;
}
EnumC13192fTf.c(c13197fTk, a2);
return c13197fTk2;
}
public static long c(TimeUnit timeUnit) {
return AbstractC13173fSu.a(timeUnit);
}
/* JADX INFO: Access modifiers changed from: package-private */
/* renamed from: o.fSu$Sts$RVV */
/* loaded from: classes6.dex */
public final class RVV implements Runnable {
private Runnable a;
private long b;
private long c;
private long d;
private C13197fTk e;
private Sts f;
private long h;
RVV(Sts sts, long j, Runnable runnable, long j2, C13197fTk c13197fTk, long j3) {
this.f = sts;
this.a = runnable;
this.e = c13197fTk;
this.c = j3;
this.b = j2;
this.h = j;
}
@Override // java.lang.Runnable
public final void run() {
long j;
this.a.run();
if (this.e.isDisposed()) {
return;
}
long c = Sts.c(TimeUnit.NANOSECONDS);
long j2 = AbstractC13173fSu.a;
long j3 = this.b;
if (j2 + c < j3 || c >= j3 + this.c + AbstractC13173fSu.a) {
long j4 = this.c;
long j5 = c + j4;
long j6 = this.d + 1;
this.d = j6;
this.h = j5 - (j4 * j6);
j = j5;
} else {
long j7 = this.h;
long j8 = this.d + 1;
this.d = j8;
j = j7 + (j8 * this.c);
}
this.b = c;
EnumC13192fTf.c(this.e, this.f.a(this, j - c, TimeUnit.NANOSECONDS));
}
}
}
/* renamed from: o.fSu$LWm */
/* loaded from: classes6.dex */
static final class LWm implements fSJ, Runnable {
private Runnable a;
private volatile boolean d;
private Sts e;
LWm(Runnable runnable, Sts sts) {
this.a = runnable;
this.e = sts;
}
@Override // java.lang.Runnable
public final void run() {
if (this.d) {
return;
}
try {
this.a.run();
} catch (Throwable th) {
dispose();
C13418fZu.c(th);
throw th;
}
}
@Override // o.fSJ
public final void dispose() {
this.d = true;
this.e.dispose();
}
@Override // o.fSJ
public final boolean isDisposed() {
return this.d;
}
}
/* JADX INFO: Access modifiers changed from: package-private */
/* renamed from: o.fSu$RVV */
/* loaded from: classes6.dex */
public static final class RVV implements fSJ, Runnable {
private Runnable c;
private Thread d;
private Sts e;
RVV(Runnable runnable, Sts sts) {
this.c = runnable;
this.e = sts;
}
@Override // java.lang.Runnable
public final void run() {
this.d = Thread.currentThread();
try {
this.c.run();
} finally {
}
}
@Override // o.fSJ
public final void dispose() {
if (this.d == Thread.currentThread()) {
Sts sts = this.e;
if (sts instanceof C13380fYs) {
C13380fYs c13380fYs = (C13380fYs) sts;
if (c13380fYs.b) {
return;
}
c13380fYs.b = true;
c13380fYs.c.shutdown();
return;
}
}
this.e.dispose();
}
@Override // o.fSJ
public final boolean isDisposed() {
return this.e.isDisposed();
}
}
}