98 lines
3.4 KiB
Java
98 lines
3.4 KiB
Java
package s.a;
|
|
|
|
import java.util.concurrent.CancellationException;
|
|
import java.util.concurrent.Executor;
|
|
import java.util.concurrent.ExecutorService;
|
|
import java.util.concurrent.RejectedExecutionException;
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
import java.util.concurrent.ScheduledFuture;
|
|
import java.util.concurrent.TimeUnit;
|
|
import kotlin.Unit;
|
|
import kotlin.coroutines.CoroutineContext;
|
|
import kotlinx.coroutines.CancellableContinuation;
|
|
import kotlinx.coroutines.ExecutorCoroutineDispatcher;
|
|
import kotlinx.coroutines.Job;
|
|
/* compiled from: Executors.kt */
|
|
public abstract class u0 extends ExecutorCoroutineDispatcher implements g0 {
|
|
public boolean i;
|
|
|
|
public final void I(CoroutineContext coroutineContext, RejectedExecutionException rejectedExecutionException) {
|
|
CancellationException cancellationException = new CancellationException("The task was rejected");
|
|
cancellationException.initCause(rejectedExecutionException);
|
|
Job job = (Job) coroutineContext.get(Job.h);
|
|
if (job != null) {
|
|
job.B(cancellationException);
|
|
}
|
|
}
|
|
|
|
public final ScheduledFuture<?> K(Runnable runnable, CoroutineContext coroutineContext, long j) {
|
|
try {
|
|
Executor H = H();
|
|
if (!(H instanceof ScheduledExecutorService)) {
|
|
H = null;
|
|
}
|
|
ScheduledExecutorService scheduledExecutorService = (ScheduledExecutorService) H;
|
|
if (scheduledExecutorService != null) {
|
|
return scheduledExecutorService.schedule(runnable, j, TimeUnit.MILLISECONDS);
|
|
}
|
|
return null;
|
|
} catch (RejectedExecutionException e) {
|
|
I(coroutineContext, e);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
@Override // s.a.g0
|
|
public void b(long j, CancellableContinuation<? super Unit> cancellableContinuation) {
|
|
ScheduledFuture<?> K = this.i ? K(new p1(this, cancellableContinuation), ((k) cancellableContinuation).n, j) : null;
|
|
if (K != null) {
|
|
((k) cancellableContinuation).e(new h(K));
|
|
} else {
|
|
c0.o.b(j, cancellableContinuation);
|
|
}
|
|
}
|
|
|
|
@Override // java.io.Closeable, java.lang.AutoCloseable
|
|
public void close() {
|
|
Executor H = H();
|
|
if (!(H instanceof ExecutorService)) {
|
|
H = null;
|
|
}
|
|
ExecutorService executorService = (ExecutorService) H;
|
|
if (executorService != null) {
|
|
executorService.shutdown();
|
|
}
|
|
}
|
|
|
|
@Override // kotlinx.coroutines.CoroutineDispatcher
|
|
public void dispatch(CoroutineContext coroutineContext, Runnable runnable) {
|
|
try {
|
|
H().execute(runnable);
|
|
} catch (RejectedExecutionException e) {
|
|
I(coroutineContext, e);
|
|
j0.b.dispatch(coroutineContext, runnable);
|
|
}
|
|
}
|
|
|
|
@Override // java.lang.Object
|
|
public boolean equals(Object obj) {
|
|
return (obj instanceof u0) && ((u0) obj).H() == H();
|
|
}
|
|
|
|
@Override // java.lang.Object
|
|
public int hashCode() {
|
|
return System.identityHashCode(H());
|
|
}
|
|
|
|
@Override // kotlinx.coroutines.CoroutineDispatcher, java.lang.Object
|
|
public String toString() {
|
|
return H().toString();
|
|
}
|
|
|
|
@Override // s.a.g0
|
|
public l0 w(long j, Runnable runnable, CoroutineContext coroutineContext) {
|
|
ScheduledFuture<?> K = this.i ? K(runnable, coroutineContext, j) : null;
|
|
return K != null ? new k0(K) : c0.o.w(j, runnable, coroutineContext);
|
|
}
|
|
}
|