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

168 lines
5.9 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package o;
import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import o.AbstractC13173fSu;
/* loaded from: classes.dex */
public final class fYF extends AbstractC13173fSu {
private static ThreadFactoryC13387fYz b;
private static ScheduledExecutorService c;
private ThreadFactory d;
private AtomicReference<ScheduledExecutorService> e;
static {
ScheduledExecutorService newScheduledThreadPool = Executors.newScheduledThreadPool(0);
c = newScheduledThreadPool;
newScheduledThreadPool.shutdown();
b = new ThreadFactoryC13387fYz("RxSingleScheduler", Math.max(1, Math.min(10, Integer.getInteger("rx3.single-priority", 5).intValue())), true);
}
public fYF() {
this(b);
}
private fYF(ThreadFactory threadFactory) {
AtomicReference<ScheduledExecutorService> atomicReference = new AtomicReference<>();
this.e = atomicReference;
this.d = threadFactory;
atomicReference.lazySet(fYB.c(threadFactory));
}
@Override // o.AbstractC13173fSu
public final void b() {
ScheduledExecutorService scheduledExecutorService = null;
while (true) {
ScheduledExecutorService scheduledExecutorService2 = this.e.get();
if (scheduledExecutorService2 != c) {
if (scheduledExecutorService != null) {
scheduledExecutorService.shutdown();
return;
}
return;
} else {
if (scheduledExecutorService == null) {
scheduledExecutorService = fYB.c(this.d);
}
AtomicReference<ScheduledExecutorService> atomicReference = this.e;
while (!atomicReference.compareAndSet(scheduledExecutorService2, scheduledExecutorService)) {
if (atomicReference.get() != scheduledExecutorService2) {
break;
}
}
return;
}
}
}
@Override // o.AbstractC13173fSu
public final AbstractC13173fSu.Sts c() {
return new HBt(this.e.get());
}
@Override // o.AbstractC13173fSu
public final fSJ d(Runnable runnable, long j, TimeUnit timeUnit) {
Future<?> schedule;
Objects.requireNonNull(runnable, "run is null");
CallableC13385fYx callableC13385fYx = new CallableC13385fYx(runnable);
try {
if (j <= 0) {
schedule = this.e.get().submit(callableC13385fYx);
} else {
schedule = this.e.get().schedule(callableC13385fYx, j, timeUnit);
}
callableC13385fYx.e(schedule);
return callableC13385fYx;
} catch (RejectedExecutionException e) {
C13418fZu.c(e);
return EnumC13195fTi.INSTANCE;
}
}
/* loaded from: classes6.dex */
static final class HBt extends AbstractC13173fSu.Sts {
private volatile boolean a;
private fSC c = new fSC();
private ScheduledExecutorService e;
HBt(ScheduledExecutorService scheduledExecutorService) {
this.e = scheduledExecutorService;
}
@Override // o.AbstractC13173fSu.Sts
public final fSJ a(Runnable runnable, long j, TimeUnit timeUnit) {
Future<?> schedule;
if (this.a) {
return EnumC13195fTi.INSTANCE;
}
Objects.requireNonNull(runnable, "run is null");
RunnableC13386fYy runnableC13386fYy = new RunnableC13386fYy(runnable, this.c);
this.c.e(runnableC13386fYy);
try {
if (j <= 0) {
schedule = this.e.submit((Callable) runnableC13386fYy);
} else {
schedule = this.e.schedule((Callable) runnableC13386fYy, j, timeUnit);
}
runnableC13386fYy.e(schedule);
return runnableC13386fYy;
} catch (RejectedExecutionException e) {
dispose();
C13418fZu.c(e);
return EnumC13195fTi.INSTANCE;
}
}
@Override // o.fSJ
public final void dispose() {
if (this.a) {
return;
}
this.a = true;
this.c.dispose();
}
@Override // o.fSJ
public final boolean isDisposed() {
return this.a;
}
}
@Override // o.AbstractC13173fSu
public final fSJ d(Runnable runnable, long j, long j2, TimeUnit timeUnit) {
Future<?> schedule;
Objects.requireNonNull(runnable, "run is null");
if (j2 <= 0) {
ScheduledExecutorService scheduledExecutorService = this.e.get();
CallableC13383fYv callableC13383fYv = new CallableC13383fYv(runnable, scheduledExecutorService);
try {
if (j <= 0) {
schedule = scheduledExecutorService.submit(callableC13383fYv);
} else {
schedule = scheduledExecutorService.schedule(callableC13383fYv, j, timeUnit);
}
callableC13383fYv.e(schedule);
return callableC13383fYv;
} catch (RejectedExecutionException e) {
C13418fZu.c(e);
return EnumC13195fTi.INSTANCE;
}
}
fYA fya = new fYA(runnable);
try {
fya.e(this.e.get().scheduleAtFixedRate(fya, j, j2, timeUnit));
return fya;
} catch (RejectedExecutionException e2) {
C13418fZu.c(e2);
return EnumC13195fTi.INSTANCE;
}
}
}