212 lines
6.8 KiB
Java
212 lines
6.8 KiB
Java
|
package o;
|
||
|
|
||
|
import java.util.Iterator;
|
||
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||
|
import java.util.concurrent.Executors;
|
||
|
import java.util.concurrent.Future;
|
||
|
import java.util.concurrent.ScheduledExecutorService;
|
||
|
import java.util.concurrent.ScheduledFuture;
|
||
|
import java.util.concurrent.ThreadFactory;
|
||
|
import java.util.concurrent.TimeUnit;
|
||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||
|
import java.util.concurrent.atomic.AtomicReference;
|
||
|
import o.AbstractC13173fSu;
|
||
|
|
||
|
/* renamed from: o.fYt, reason: case insensitive filesystem */
|
||
|
/* loaded from: classes.dex */
|
||
|
public final class C13381fYt extends AbstractC13173fSu {
|
||
|
static final ThreadFactoryC13387fYz b;
|
||
|
static final Sts c;
|
||
|
static boolean d = false;
|
||
|
private static ThreadFactoryC13387fYz g;
|
||
|
private static IeS i;
|
||
|
private ThreadFactory f;
|
||
|
private AtomicReference<IeS> h;
|
||
|
private static final TimeUnit j = TimeUnit.SECONDS;
|
||
|
private static final long e = Long.getLong("rx3.io-keep-alive-time", 60).longValue();
|
||
|
|
||
|
static {
|
||
|
Sts sts = new Sts(new ThreadFactoryC13387fYz("RxCachedThreadSchedulerShutdown"));
|
||
|
c = sts;
|
||
|
sts.dispose();
|
||
|
int max = Math.max(1, Math.min(10, Integer.getInteger("rx3.io-priority", 5).intValue()));
|
||
|
ThreadFactoryC13387fYz threadFactoryC13387fYz = new ThreadFactoryC13387fYz("RxCachedThreadScheduler", max);
|
||
|
g = threadFactoryC13387fYz;
|
||
|
b = new ThreadFactoryC13387fYz("RxCachedWorkerPoolEvictor", max);
|
||
|
d = Boolean.getBoolean("rx3.io-scheduled-release");
|
||
|
IeS ieS = new IeS(0L, null, threadFactoryC13387fYz);
|
||
|
i = ieS;
|
||
|
ieS.a();
|
||
|
}
|
||
|
|
||
|
/* renamed from: o.fYt$IeS */
|
||
|
/* loaded from: classes.dex */
|
||
|
static final class IeS implements Runnable {
|
||
|
final ThreadFactory a;
|
||
|
private final ScheduledExecutorService b;
|
||
|
final fSC c;
|
||
|
final long d;
|
||
|
final ConcurrentLinkedQueue<Sts> e;
|
||
|
private final Future<?> j;
|
||
|
|
||
|
IeS(long j, TimeUnit timeUnit, ThreadFactory threadFactory) {
|
||
|
ScheduledExecutorService scheduledExecutorService;
|
||
|
ScheduledFuture<?> scheduledFuture;
|
||
|
long nanos = timeUnit != null ? timeUnit.toNanos(j) : 0L;
|
||
|
this.d = nanos;
|
||
|
this.e = new ConcurrentLinkedQueue<>();
|
||
|
this.c = new fSC();
|
||
|
this.a = threadFactory;
|
||
|
if (timeUnit != null) {
|
||
|
scheduledExecutorService = Executors.newScheduledThreadPool(1, C13381fYt.b);
|
||
|
scheduledFuture = scheduledExecutorService.scheduleWithFixedDelay(this, nanos, nanos, TimeUnit.NANOSECONDS);
|
||
|
} else {
|
||
|
scheduledExecutorService = null;
|
||
|
scheduledFuture = null;
|
||
|
}
|
||
|
this.b = scheduledExecutorService;
|
||
|
this.j = scheduledFuture;
|
||
|
}
|
||
|
|
||
|
final void a() {
|
||
|
this.c.dispose();
|
||
|
Future<?> future = this.j;
|
||
|
if (future != null) {
|
||
|
future.cancel(true);
|
||
|
}
|
||
|
ScheduledExecutorService scheduledExecutorService = this.b;
|
||
|
if (scheduledExecutorService != null) {
|
||
|
scheduledExecutorService.shutdownNow();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // java.lang.Runnable
|
||
|
public final void run() {
|
||
|
ConcurrentLinkedQueue<Sts> concurrentLinkedQueue = this.e;
|
||
|
fSC fsc = this.c;
|
||
|
if (concurrentLinkedQueue.isEmpty()) {
|
||
|
return;
|
||
|
}
|
||
|
long nanoTime = System.nanoTime();
|
||
|
Iterator<Sts> it = concurrentLinkedQueue.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
Sts next = it.next();
|
||
|
if (next.d > nanoTime) {
|
||
|
return;
|
||
|
}
|
||
|
if (concurrentLinkedQueue.remove(next) && fsc.b(next)) {
|
||
|
next.dispose();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public C13381fYt() {
|
||
|
this(g);
|
||
|
}
|
||
|
|
||
|
private C13381fYt(ThreadFactory threadFactory) {
|
||
|
this.f = threadFactory;
|
||
|
this.h = new AtomicReference<>(i);
|
||
|
b();
|
||
|
}
|
||
|
|
||
|
@Override // o.AbstractC13173fSu
|
||
|
public final void b() {
|
||
|
IeS ieS = new IeS(e, j, this.f);
|
||
|
AtomicReference<IeS> atomicReference = this.h;
|
||
|
IeS ieS2 = i;
|
||
|
while (!atomicReference.compareAndSet(ieS2, ieS)) {
|
||
|
if (atomicReference.get() != ieS2) {
|
||
|
ieS.a();
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // o.AbstractC13173fSu
|
||
|
public final AbstractC13173fSu.Sts c() {
|
||
|
return new LWm(this.h.get());
|
||
|
}
|
||
|
|
||
|
/* renamed from: o.fYt$LWm */
|
||
|
/* loaded from: classes6.dex */
|
||
|
static final class LWm extends AbstractC13173fSu.Sts implements Runnable {
|
||
|
private final IeS a;
|
||
|
private final Sts b;
|
||
|
private AtomicBoolean c = new AtomicBoolean();
|
||
|
private final fSC d = new fSC();
|
||
|
|
||
|
LWm(IeS ieS) {
|
||
|
Sts sts;
|
||
|
Sts sts2;
|
||
|
this.a = ieS;
|
||
|
if (ieS.c.isDisposed()) {
|
||
|
sts2 = C13381fYt.c;
|
||
|
this.b = sts2;
|
||
|
}
|
||
|
while (true) {
|
||
|
if (!ieS.e.isEmpty()) {
|
||
|
sts = ieS.e.poll();
|
||
|
if (sts != null) {
|
||
|
break;
|
||
|
}
|
||
|
} else {
|
||
|
sts = new Sts(ieS.a);
|
||
|
ieS.c.e(sts);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
sts2 = sts;
|
||
|
this.b = sts2;
|
||
|
}
|
||
|
|
||
|
@Override // o.fSJ
|
||
|
public final void dispose() {
|
||
|
if (this.c.compareAndSet(false, true)) {
|
||
|
this.d.dispose();
|
||
|
if (C13381fYt.d) {
|
||
|
this.b.c(this, 0L, TimeUnit.NANOSECONDS, (InterfaceC13145fSF) null);
|
||
|
return;
|
||
|
}
|
||
|
IeS ieS = this.a;
|
||
|
Sts sts = this.b;
|
||
|
sts.d = System.nanoTime() + ieS.d;
|
||
|
ieS.e.offer(sts);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // o.fSJ
|
||
|
public final boolean isDisposed() {
|
||
|
return this.c.get();
|
||
|
}
|
||
|
|
||
|
@Override // o.AbstractC13173fSu.Sts
|
||
|
public final fSJ a(Runnable runnable, long j, TimeUnit timeUnit) {
|
||
|
if (this.d.isDisposed()) {
|
||
|
return EnumC13195fTi.INSTANCE;
|
||
|
}
|
||
|
return this.b.c(runnable, j, timeUnit, this.d);
|
||
|
}
|
||
|
|
||
|
@Override // java.lang.Runnable
|
||
|
public final void run() {
|
||
|
IeS ieS = this.a;
|
||
|
Sts sts = this.b;
|
||
|
sts.d = System.nanoTime() + ieS.d;
|
||
|
ieS.e.offer(sts);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* renamed from: o.fYt$Sts */
|
||
|
/* loaded from: classes.dex */
|
||
|
static final class Sts extends C13380fYs {
|
||
|
long d;
|
||
|
|
||
|
Sts(ThreadFactory threadFactory) {
|
||
|
super(threadFactory);
|
||
|
this.d = 0L;
|
||
|
}
|
||
|
}
|
||
|
}
|