ADD week 5
This commit is contained in:
File diff suppressed because one or more lines are too long
@ -0,0 +1,17 @@
|
||||
package kotlinx.coroutines.scheduling;
|
||||
|
||||
import kotlin.Metadata;
|
||||
import kotlinx.coroutines.scheduling.CoroutineScheduler;
|
||||
|
||||
/* compiled from: CoroutineScheduler.kt */
|
||||
@Metadata(d1 = {"\u0000\u0010\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\u001a\u0010\u0010\u0000\u001a\u00020\u00012\u0006\u0010\u0002\u001a\u00020\u0003H\u0001\u001a\u0010\u0010\u0004\u001a\u00020\u00012\u0006\u0010\u0002\u001a\u00020\u0003H\u0001¨\u0006\u0005"}, d2 = {"isSchedulerWorker", "", "thread", "Ljava/lang/Thread;", "mayNotBlock", "kotlinx-coroutines-core"}, k = 2, mv = {1, 8, 0}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
public final class CoroutineSchedulerKt {
|
||||
public static final boolean isSchedulerWorker(Thread thread) {
|
||||
return thread instanceof CoroutineScheduler.Worker;
|
||||
}
|
||||
|
||||
public static final boolean mayNotBlock(Thread thread) {
|
||||
return (thread instanceof CoroutineScheduler.Worker) && ((CoroutineScheduler.Worker) thread).state == CoroutineScheduler.WorkerState.CPU_ACQUIRED;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package kotlinx.coroutines.scheduling;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import kotlin.Metadata;
|
||||
import kotlin.coroutines.CoroutineContext;
|
||||
import kotlin.coroutines.EmptyCoroutineContext;
|
||||
import kotlin.ranges.RangesKt;
|
||||
import kotlinx.coroutines.CoroutineDispatcher;
|
||||
import kotlinx.coroutines.DispatchersKt;
|
||||
import kotlinx.coroutines.ExecutorCoroutineDispatcher;
|
||||
import kotlinx.coroutines.internal.SystemPropsKt;
|
||||
import kotlinx.coroutines.internal.SystemPropsKt__SystemProps_commonKt;
|
||||
|
||||
/* compiled from: Dispatcher.kt */
|
||||
@Metadata(d1 = {"\u0000>\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u000e\n\u0000\bÀ\u0002\u0018\u00002\u00020\u00012\u00020\u0002B\u0007\b\u0002¢\u0006\u0002\u0010\u0003J\b\u0010\t\u001a\u00020\nH\u0016J\u001c\u0010\u000b\u001a\u00020\n2\u0006\u0010\f\u001a\u00020\r2\n\u0010\u000e\u001a\u00060\u000fj\u0002`\u0010H\u0016J\u001c\u0010\u0011\u001a\u00020\n2\u0006\u0010\f\u001a\u00020\r2\n\u0010\u000e\u001a\u00060\u000fj\u0002`\u0010H\u0017J\u0010\u0010\u0012\u001a\u00020\n2\u0006\u0010\u0013\u001a\u00020\u000fH\u0016J\u0010\u0010\u0014\u001a\u00020\u00052\u0006\u0010\u0015\u001a\u00020\u0016H\u0017J\b\u0010\u0017\u001a\u00020\u0018H\u0016R\u000e\u0010\u0004\u001a\u00020\u0005X\u0082\u0004¢\u0006\u0002\n\u0000R\u0014\u0010\u0006\u001a\u00020\u00028VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\u0007\u0010\b¨\u0006\u0019"}, d2 = {"Lkotlinx/coroutines/scheduling/DefaultIoScheduler;", "Lkotlinx/coroutines/ExecutorCoroutineDispatcher;", "Ljava/util/concurrent/Executor;", "()V", "default", "Lkotlinx/coroutines/CoroutineDispatcher;", "executor", "getExecutor", "()Ljava/util/concurrent/Executor;", "close", "", "dispatch", "context", "Lkotlin/coroutines/CoroutineContext;", "block", "Ljava/lang/Runnable;", "Lkotlinx/coroutines/Runnable;", "dispatchYield", "execute", "command", "limitedParallelism", "parallelism", "", "toString", "", "kotlinx-coroutines-core"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
public final class DefaultIoScheduler extends ExecutorCoroutineDispatcher implements Executor {
|
||||
public static final DefaultIoScheduler INSTANCE = new DefaultIoScheduler();
|
||||
private static final CoroutineDispatcher default;
|
||||
|
||||
@Override // kotlinx.coroutines.CoroutineDispatcher
|
||||
public String toString() {
|
||||
return "Dispatchers.IO";
|
||||
}
|
||||
|
||||
private DefaultIoScheduler() {
|
||||
}
|
||||
|
||||
static {
|
||||
int systemProp$default;
|
||||
UnlimitedIoScheduler unlimitedIoScheduler = UnlimitedIoScheduler.INSTANCE;
|
||||
systemProp$default = SystemPropsKt__SystemProps_commonKt.systemProp$default(DispatchersKt.IO_PARALLELISM_PROPERTY_NAME, RangesKt.coerceAtLeast(64, SystemPropsKt.getAVAILABLE_PROCESSORS()), 0, 0, 12, (Object) null);
|
||||
default = unlimitedIoScheduler.limitedParallelism(systemProp$default);
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.ExecutorCoroutineDispatcher
|
||||
public Executor getExecutor() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.Executor
|
||||
public void execute(Runnable command) {
|
||||
mo1907dispatch(EmptyCoroutineContext.INSTANCE, command);
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.CoroutineDispatcher
|
||||
public CoroutineDispatcher limitedParallelism(int parallelism) {
|
||||
return UnlimitedIoScheduler.INSTANCE.limitedParallelism(parallelism);
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.CoroutineDispatcher
|
||||
/* renamed from: dispatch */
|
||||
public void mo1907dispatch(CoroutineContext context, Runnable block) {
|
||||
default.mo1907dispatch(context, block);
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.CoroutineDispatcher
|
||||
public void dispatchYield(CoroutineContext context, Runnable block) {
|
||||
default.dispatchYield(context, block);
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.ExecutorCoroutineDispatcher, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() {
|
||||
throw new IllegalStateException("Cannot be invoked on Dispatchers.IO".toString());
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package kotlinx.coroutines.scheduling;
|
||||
|
||||
import kotlin.Metadata;
|
||||
import kotlinx.coroutines.CoroutineDispatcher;
|
||||
import kotlinx.coroutines.internal.LimitedDispatcherKt;
|
||||
|
||||
/* compiled from: Dispatcher.kt */
|
||||
@Metadata(d1 = {"\u0000&\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0000\bÀ\u0002\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\b\u0010\u0003\u001a\u00020\u0004H\u0016J\u0010\u0010\u0005\u001a\u00020\u00062\u0006\u0010\u0007\u001a\u00020\bH\u0017J\r\u0010\t\u001a\u00020\u0004H\u0000¢\u0006\u0002\b\nJ\b\u0010\u000b\u001a\u00020\fH\u0016¨\u0006\r"}, d2 = {"Lkotlinx/coroutines/scheduling/DefaultScheduler;", "Lkotlinx/coroutines/scheduling/SchedulerCoroutineDispatcher;", "()V", "close", "", "limitedParallelism", "Lkotlinx/coroutines/CoroutineDispatcher;", "parallelism", "", "shutdown", "shutdown$kotlinx_coroutines_core", "toString", "", "kotlinx-coroutines-core"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
public final class DefaultScheduler extends SchedulerCoroutineDispatcher {
|
||||
public static final DefaultScheduler INSTANCE = new DefaultScheduler();
|
||||
|
||||
@Override // kotlinx.coroutines.CoroutineDispatcher
|
||||
public String toString() {
|
||||
return "Dispatchers.Default";
|
||||
}
|
||||
|
||||
private DefaultScheduler() {
|
||||
super(TasksKt.CORE_POOL_SIZE, TasksKt.MAX_POOL_SIZE, TasksKt.IDLE_WORKER_KEEP_ALIVE_NS, TasksKt.DEFAULT_SCHEDULER_NAME);
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.CoroutineDispatcher
|
||||
public CoroutineDispatcher limitedParallelism(int parallelism) {
|
||||
LimitedDispatcherKt.checkParallelism(parallelism);
|
||||
return parallelism >= TasksKt.CORE_POOL_SIZE ? this : super.limitedParallelism(parallelism);
|
||||
}
|
||||
|
||||
public final void shutdown$kotlinx_coroutines_core() {
|
||||
super.close();
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.scheduling.SchedulerCoroutineDispatcher, kotlinx.coroutines.ExecutorCoroutineDispatcher, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() {
|
||||
throw new UnsupportedOperationException("Dispatchers.Default cannot be closed");
|
||||
}
|
||||
}
|
@ -0,0 +1,125 @@
|
||||
package kotlinx.coroutines.scheduling;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.RejectedExecutionException;
|
||||
import kotlin.Deprecated;
|
||||
import kotlin.DeprecationLevel;
|
||||
import kotlin.Metadata;
|
||||
import kotlin.coroutines.CoroutineContext;
|
||||
import kotlin.jvm.internal.DefaultConstructorMarker;
|
||||
import kotlinx.coroutines.CoroutineDispatcher;
|
||||
import kotlinx.coroutines.DefaultExecutor;
|
||||
import kotlinx.coroutines.ExecutorCoroutineDispatcher;
|
||||
|
||||
/* compiled from: Deprecated.kt */
|
||||
@Metadata(d1 = {"\u0000^\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0010\t\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0005\b\u0011\u0018\u00002\u00020\u0001B%\b\u0016\u0012\b\b\u0002\u0010\u0002\u001a\u00020\u0003\u0012\b\b\u0002\u0010\u0004\u001a\u00020\u0003\u0012\b\b\u0002\u0010\u0005\u001a\u00020\u0006¢\u0006\u0002\u0010\u0007B\u001b\b\u0017\u0012\b\b\u0002\u0010\u0002\u001a\u00020\u0003\u0012\b\b\u0002\u0010\u0004\u001a\u00020\u0003¢\u0006\u0002\u0010\bB'\u0012\u0006\u0010\u0002\u001a\u00020\u0003\u0012\u0006\u0010\u0004\u001a\u00020\u0003\u0012\u0006\u0010\t\u001a\u00020\n\u0012\b\b\u0002\u0010\u0005\u001a\u00020\u0006¢\u0006\u0002\u0010\u000bJ\u0010\u0010\u0012\u001a\u00020\u00132\b\b\u0002\u0010\u0014\u001a\u00020\u0003J\b\u0010\u0015\u001a\u00020\u0016H\u0016J\b\u0010\u0017\u001a\u00020\rH\u0002J\u001c\u0010\u0018\u001a\u00020\u00162\u0006\u0010\u0019\u001a\u00020\u001a2\n\u0010\u001b\u001a\u00060\u001cj\u0002`\u001dH\u0016J)\u0010\u001e\u001a\u00020\u00162\n\u0010\u001b\u001a\u00060\u001cj\u0002`\u001d2\u0006\u0010\u0019\u001a\u00020\u001f2\u0006\u0010 \u001a\u00020!H\u0000¢\u0006\u0002\b\"J\u001c\u0010#\u001a\u00020\u00162\u0006\u0010\u0019\u001a\u00020\u001a2\n\u0010\u001b\u001a\u00060\u001cj\u0002`\u001dH\u0016J\u000e\u0010$\u001a\u00020\u00132\u0006\u0010\u0014\u001a\u00020\u0003J\b\u0010%\u001a\u00020\u0006H\u0016R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\f\u001a\u00020\rX\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\u000e\u001a\u00020\u000f8VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\u0010\u0010\u0011R\u000e\u0010\t\u001a\u00020\nX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0004\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0006X\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006&"}, d2 = {"Lkotlinx/coroutines/scheduling/ExperimentalCoroutineDispatcher;", "Lkotlinx/coroutines/ExecutorCoroutineDispatcher;", "corePoolSize", "", "maxPoolSize", "schedulerName", "", "(IILjava/lang/String;)V", "(II)V", "idleWorkerKeepAliveNs", "", "(IIJLjava/lang/String;)V", "coroutineScheduler", "Lkotlinx/coroutines/scheduling/CoroutineScheduler;", "executor", "Ljava/util/concurrent/Executor;", "getExecutor", "()Ljava/util/concurrent/Executor;", "blocking", "Lkotlinx/coroutines/CoroutineDispatcher;", "parallelism", "close", "", "createScheduler", "dispatch", "context", "Lkotlin/coroutines/CoroutineContext;", "block", "Ljava/lang/Runnable;", "Lkotlinx/coroutines/Runnable;", "dispatchWithContext", "Lkotlinx/coroutines/scheduling/TaskContext;", "tailDispatch", "", "dispatchWithContext$kotlinx_coroutines_core", "dispatchYield", "limited", "toString", "kotlinx-coroutines-core"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
public class ExperimentalCoroutineDispatcher extends ExecutorCoroutineDispatcher {
|
||||
private final int corePoolSize;
|
||||
private CoroutineScheduler coroutineScheduler;
|
||||
private final long idleWorkerKeepAliveNs;
|
||||
private final int maxPoolSize;
|
||||
private final String schedulerName;
|
||||
|
||||
public /* synthetic */ ExperimentalCoroutineDispatcher(int i, int i2, long j, String str, int i3, DefaultConstructorMarker defaultConstructorMarker) {
|
||||
this(i, i2, j, (i3 & 8) != 0 ? "CoroutineScheduler" : str);
|
||||
}
|
||||
|
||||
public ExperimentalCoroutineDispatcher(int i, int i2, long j, String str) {
|
||||
this.corePoolSize = i;
|
||||
this.maxPoolSize = i2;
|
||||
this.idleWorkerKeepAliveNs = j;
|
||||
this.schedulerName = str;
|
||||
this.coroutineScheduler = createScheduler();
|
||||
}
|
||||
|
||||
public /* synthetic */ ExperimentalCoroutineDispatcher(int i, int i2, String str, int i3, DefaultConstructorMarker defaultConstructorMarker) {
|
||||
this((i3 & 1) != 0 ? TasksKt.CORE_POOL_SIZE : i, (i3 & 2) != 0 ? TasksKt.MAX_POOL_SIZE : i2, (i3 & 4) != 0 ? TasksKt.DEFAULT_SCHEDULER_NAME : str);
|
||||
}
|
||||
|
||||
public ExperimentalCoroutineDispatcher(int i, int i2, String str) {
|
||||
this(i, i2, TasksKt.IDLE_WORKER_KEEP_ALIVE_NS, str);
|
||||
}
|
||||
|
||||
public /* synthetic */ ExperimentalCoroutineDispatcher(int i, int i2, int i3, DefaultConstructorMarker defaultConstructorMarker) {
|
||||
this((i3 & 1) != 0 ? TasksKt.CORE_POOL_SIZE : i, (i3 & 2) != 0 ? TasksKt.MAX_POOL_SIZE : i2);
|
||||
}
|
||||
|
||||
@Deprecated(level = DeprecationLevel.HIDDEN, message = "Binary compatibility for Ktor 1.0-beta")
|
||||
public /* synthetic */ ExperimentalCoroutineDispatcher(int i, int i2) {
|
||||
this(i, i2, TasksKt.IDLE_WORKER_KEEP_ALIVE_NS, null, 8, null);
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.ExecutorCoroutineDispatcher
|
||||
public Executor getExecutor() {
|
||||
return this.coroutineScheduler;
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.CoroutineDispatcher
|
||||
/* renamed from: dispatch */
|
||||
public void mo1907dispatch(CoroutineContext context, Runnable block) {
|
||||
try {
|
||||
CoroutineScheduler.dispatch$default(this.coroutineScheduler, block, null, false, 6, null);
|
||||
} catch (RejectedExecutionException unused) {
|
||||
DefaultExecutor.INSTANCE.mo1907dispatch(context, block);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.CoroutineDispatcher
|
||||
public void dispatchYield(CoroutineContext context, Runnable block) {
|
||||
try {
|
||||
CoroutineScheduler.dispatch$default(this.coroutineScheduler, block, null, true, 2, null);
|
||||
} catch (RejectedExecutionException unused) {
|
||||
DefaultExecutor.INSTANCE.dispatchYield(context, block);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.ExecutorCoroutineDispatcher, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() {
|
||||
this.coroutineScheduler.close();
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.CoroutineDispatcher
|
||||
public String toString() {
|
||||
return super.toString() + "[scheduler = " + this.coroutineScheduler + ']';
|
||||
}
|
||||
|
||||
public static /* synthetic */ CoroutineDispatcher blocking$default(ExperimentalCoroutineDispatcher experimentalCoroutineDispatcher, int i, int i2, Object obj) {
|
||||
if (obj != null) {
|
||||
throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: blocking");
|
||||
}
|
||||
if ((i2 & 1) != 0) {
|
||||
i = 16;
|
||||
}
|
||||
return experimentalCoroutineDispatcher.blocking(i);
|
||||
}
|
||||
|
||||
public final CoroutineDispatcher blocking(int parallelism) {
|
||||
if (parallelism <= 0) {
|
||||
throw new IllegalArgumentException(("Expected positive parallelism level, but have " + parallelism).toString());
|
||||
}
|
||||
return new LimitingDispatcher(this, parallelism, null, 1);
|
||||
}
|
||||
|
||||
public final CoroutineDispatcher limited(int parallelism) {
|
||||
if (parallelism <= 0) {
|
||||
throw new IllegalArgumentException(("Expected positive parallelism level, but have " + parallelism).toString());
|
||||
}
|
||||
if (parallelism > this.corePoolSize) {
|
||||
throw new IllegalArgumentException(("Expected parallelism level lesser than core pool size (" + this.corePoolSize + "), but have " + parallelism).toString());
|
||||
}
|
||||
return new LimitingDispatcher(this, parallelism, null, 0);
|
||||
}
|
||||
|
||||
public final void dispatchWithContext$kotlinx_coroutines_core(Runnable block, TaskContext context, boolean tailDispatch) {
|
||||
try {
|
||||
this.coroutineScheduler.dispatch(block, context, tailDispatch);
|
||||
} catch (RejectedExecutionException unused) {
|
||||
DefaultExecutor.INSTANCE.enqueue(this.coroutineScheduler.createTask(block, context));
|
||||
}
|
||||
}
|
||||
|
||||
private final CoroutineScheduler createScheduler() {
|
||||
return new CoroutineScheduler(this.corePoolSize, this.maxPoolSize, this.idleWorkerKeepAliveNs, this.schedulerName);
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package kotlinx.coroutines.scheduling;
|
||||
|
||||
import kotlin.Metadata;
|
||||
import kotlinx.coroutines.internal.LockFreeTaskQueue;
|
||||
|
||||
/* compiled from: Tasks.kt */
|
||||
@Metadata(d1 = {"\u0000\u0010\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0000\u0018\u00002\b\u0012\u0004\u0012\u00020\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0003¨\u0006\u0004"}, d2 = {"Lkotlinx/coroutines/scheduling/GlobalQueue;", "Lkotlinx/coroutines/internal/LockFreeTaskQueue;", "Lkotlinx/coroutines/scheduling/Task;", "()V", "kotlinx-coroutines-core"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
public final class GlobalQueue extends LockFreeTaskQueue<Task> {
|
||||
public GlobalQueue() {
|
||||
super(false);
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package kotlinx.coroutines.scheduling;
|
||||
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
|
||||
import kotlin.Metadata;
|
||||
import kotlin.coroutines.CoroutineContext;
|
||||
import kotlin.jvm.Volatile;
|
||||
import kotlinx.coroutines.ExecutorCoroutineDispatcher;
|
||||
|
||||
/* compiled from: Deprecated.kt */
|
||||
@Metadata(d1 = {"\u0000T\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0005\b\u0002\u0018\u00002\u00020\u00012\u00020\u00022\u00020\u0003B'\u0012\u0006\u0010\u0004\u001a\u00020\u0005\u0012\u0006\u0010\u0006\u001a\u00020\u0007\u0012\b\u0010\b\u001a\u0004\u0018\u00010\t\u0012\u0006\u0010\n\u001a\u00020\u0007¢\u0006\u0002\u0010\u000bJ\b\u0010\u0017\u001a\u00020\u0018H\u0016J\b\u0010\u0019\u001a\u00020\u0018H\u0016J\u001c\u0010\u001a\u001a\u00020\u00182\u0006\u0010\u001b\u001a\u00020\u001c2\n\u0010\u001d\u001a\u00060\u0013j\u0002`\u0014H\u0016J\u001c\u0010\u001a\u001a\u00020\u00182\n\u0010\u001d\u001a\u00060\u0013j\u0002`\u00142\u0006\u0010\u001e\u001a\u00020\u001fH\u0002J\u001c\u0010 \u001a\u00020\u00182\u0006\u0010\u001b\u001a\u00020\u001c2\n\u0010\u001d\u001a\u00060\u0013j\u0002`\u0014H\u0016J\u0014\u0010!\u001a\u00020\u00182\n\u0010\"\u001a\u00060\u0013j\u0002`\u0014H\u0016J\b\u0010#\u001a\u00020\tH\u0016R\u000e\u0010\u0004\u001a\u00020\u0005X\u0082\u0004¢\u0006\u0002\n\u0000R\u0014\u0010\f\u001a\u00020\u00038VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\r\u0010\u000eR\t\u0010\u000f\u001a\u00020\u0010X\u0082\u0004R\u0010\u0010\b\u001a\u0004\u0018\u00010\tX\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0007X\u0082\u0004¢\u0006\u0002\n\u0000R\u0018\u0010\u0011\u001a\f\u0012\b\u0012\u00060\u0013j\u0002`\u00140\u0012X\u0082\u0004¢\u0006\u0002\n\u0000R\u0014\u0010\n\u001a\u00020\u0007X\u0096\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0015\u0010\u0016¨\u0006$"}, d2 = {"Lkotlinx/coroutines/scheduling/LimitingDispatcher;", "Lkotlinx/coroutines/ExecutorCoroutineDispatcher;", "Lkotlinx/coroutines/scheduling/TaskContext;", "Ljava/util/concurrent/Executor;", "dispatcher", "Lkotlinx/coroutines/scheduling/ExperimentalCoroutineDispatcher;", "parallelism", "", "name", "", "taskMode", "(Lkotlinx/coroutines/scheduling/ExperimentalCoroutineDispatcher;ILjava/lang/String;I)V", "executor", "getExecutor", "()Ljava/util/concurrent/Executor;", "inFlightTasks", "Lkotlinx/atomicfu/AtomicInt;", "queue", "Ljava/util/concurrent/ConcurrentLinkedQueue;", "Ljava/lang/Runnable;", "Lkotlinx/coroutines/Runnable;", "getTaskMode", "()I", "afterTask", "", "close", "dispatch", "context", "Lkotlin/coroutines/CoroutineContext;", "block", "tailDispatch", "", "dispatchYield", "execute", "command", "toString", "kotlinx-coroutines-core"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
final class LimitingDispatcher extends ExecutorCoroutineDispatcher implements TaskContext, Executor {
|
||||
private static final AtomicIntegerFieldUpdater inFlightTasks$FU = AtomicIntegerFieldUpdater.newUpdater(LimitingDispatcher.class, "inFlightTasks");
|
||||
private final ExperimentalCoroutineDispatcher dispatcher;
|
||||
|
||||
@Volatile
|
||||
private volatile int inFlightTasks;
|
||||
private final String name;
|
||||
private final int parallelism;
|
||||
private final ConcurrentLinkedQueue<Runnable> queue = new ConcurrentLinkedQueue<>();
|
||||
private final int taskMode;
|
||||
|
||||
@Override // kotlinx.coroutines.scheduling.TaskContext
|
||||
public int getTaskMode() {
|
||||
return this.taskMode;
|
||||
}
|
||||
|
||||
public LimitingDispatcher(ExperimentalCoroutineDispatcher experimentalCoroutineDispatcher, int i, String str, int i2) {
|
||||
this.dispatcher = experimentalCoroutineDispatcher;
|
||||
this.parallelism = i;
|
||||
this.name = str;
|
||||
this.taskMode = i2;
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.ExecutorCoroutineDispatcher
|
||||
public Executor getExecutor() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.Executor
|
||||
public void execute(Runnable command) {
|
||||
dispatch(command, false);
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.ExecutorCoroutineDispatcher, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() {
|
||||
throw new IllegalStateException("Close cannot be invoked on LimitingBlockingDispatcher".toString());
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.CoroutineDispatcher
|
||||
/* renamed from: dispatch */
|
||||
public void mo1907dispatch(CoroutineContext context, Runnable block) {
|
||||
dispatch(block, false);
|
||||
}
|
||||
|
||||
private final void dispatch(Runnable block, boolean tailDispatch) {
|
||||
do {
|
||||
AtomicIntegerFieldUpdater atomicIntegerFieldUpdater = inFlightTasks$FU;
|
||||
if (atomicIntegerFieldUpdater.incrementAndGet(this) <= this.parallelism) {
|
||||
this.dispatcher.dispatchWithContext$kotlinx_coroutines_core(block, this, tailDispatch);
|
||||
return;
|
||||
}
|
||||
this.queue.add(block);
|
||||
if (atomicIntegerFieldUpdater.decrementAndGet(this) >= this.parallelism) {
|
||||
return;
|
||||
} else {
|
||||
block = this.queue.poll();
|
||||
}
|
||||
} while (block != null);
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.CoroutineDispatcher
|
||||
public void dispatchYield(CoroutineContext context, Runnable block) {
|
||||
dispatch(block, true);
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.CoroutineDispatcher
|
||||
public String toString() {
|
||||
String str = this.name;
|
||||
if (str != null) {
|
||||
return str;
|
||||
}
|
||||
return super.toString() + "[dispatcher = " + this.dispatcher + ']';
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.scheduling.TaskContext
|
||||
public void afterTask() {
|
||||
Runnable poll = this.queue.poll();
|
||||
if (poll != null) {
|
||||
this.dispatcher.dispatchWithContext$kotlinx_coroutines_core(poll, this, true);
|
||||
return;
|
||||
}
|
||||
inFlightTasks$FU.decrementAndGet(this);
|
||||
Runnable poll2 = this.queue.poll();
|
||||
if (poll2 == null) {
|
||||
return;
|
||||
}
|
||||
dispatch(poll2, true);
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package kotlinx.coroutines.scheduling;
|
||||
|
||||
import kotlin.Metadata;
|
||||
|
||||
/* compiled from: Tasks.kt */
|
||||
@Metadata(d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\t\n\u0000\bÀ\u0002\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\b\u0010\u0003\u001a\u00020\u0004H\u0016¨\u0006\u0005"}, d2 = {"Lkotlinx/coroutines/scheduling/NanoTimeSource;", "Lkotlinx/coroutines/scheduling/SchedulerTimeSource;", "()V", "nanoTime", "", "kotlinx-coroutines-core"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
public final class NanoTimeSource extends SchedulerTimeSource {
|
||||
public static final NanoTimeSource INSTANCE = new NanoTimeSource();
|
||||
|
||||
private NanoTimeSource() {
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.scheduling.SchedulerTimeSource
|
||||
public long nanoTime() {
|
||||
return System.nanoTime();
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package kotlinx.coroutines.scheduling;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
import kotlin.Metadata;
|
||||
import kotlin.coroutines.CoroutineContext;
|
||||
import kotlin.jvm.internal.DefaultConstructorMarker;
|
||||
import kotlinx.coroutines.ExecutorCoroutineDispatcher;
|
||||
|
||||
/* compiled from: Dispatcher.kt */
|
||||
@Metadata(d1 = {"\u0000T\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\t\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\n\b\u0010\u0018\u00002\u00020\u0001B-\u0012\b\b\u0002\u0010\u0002\u001a\u00020\u0003\u0012\b\b\u0002\u0010\u0004\u001a\u00020\u0003\u0012\b\b\u0002\u0010\u0005\u001a\u00020\u0006\u0012\b\b\u0002\u0010\u0007\u001a\u00020\b¢\u0006\u0002\u0010\tJ\b\u0010\u0010\u001a\u00020\u0011H\u0016J\b\u0010\u0012\u001a\u00020\u000bH\u0002J\u001c\u0010\u0013\u001a\u00020\u00112\u0006\u0010\u0014\u001a\u00020\u00152\n\u0010\u0016\u001a\u00060\u0017j\u0002`\u0018H\u0016J)\u0010\u0019\u001a\u00020\u00112\n\u0010\u0016\u001a\u00060\u0017j\u0002`\u00182\u0006\u0010\u0014\u001a\u00020\u001a2\u0006\u0010\u001b\u001a\u00020\u001cH\u0000¢\u0006\u0002\b\u001dJ\u001c\u0010\u001e\u001a\u00020\u00112\u0006\u0010\u0014\u001a\u00020\u00152\n\u0010\u0016\u001a\u00060\u0017j\u0002`\u0018H\u0016J\r\u0010\u001f\u001a\u00020\u0011H\u0000¢\u0006\u0002\b J\u0015\u0010!\u001a\u00020\u00112\u0006\u0010\"\u001a\u00020\u0006H\u0000¢\u0006\u0002\b#J\r\u0010$\u001a\u00020\u0011H\u0000¢\u0006\u0002\b%R\u000e\u0010\u0002\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\n\u001a\u00020\u000bX\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\f\u001a\u00020\r8VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\u000e\u0010\u000fR\u000e\u0010\u0005\u001a\u00020\u0006X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0004\u001a\u00020\u0003X\u0082\u0004¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\bX\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006&"}, d2 = {"Lkotlinx/coroutines/scheduling/SchedulerCoroutineDispatcher;", "Lkotlinx/coroutines/ExecutorCoroutineDispatcher;", "corePoolSize", "", "maxPoolSize", "idleWorkerKeepAliveNs", "", "schedulerName", "", "(IIJLjava/lang/String;)V", "coroutineScheduler", "Lkotlinx/coroutines/scheduling/CoroutineScheduler;", "executor", "Ljava/util/concurrent/Executor;", "getExecutor", "()Ljava/util/concurrent/Executor;", "close", "", "createScheduler", "dispatch", "context", "Lkotlin/coroutines/CoroutineContext;", "block", "Ljava/lang/Runnable;", "Lkotlinx/coroutines/Runnable;", "dispatchWithContext", "Lkotlinx/coroutines/scheduling/TaskContext;", "tailDispatch", "", "dispatchWithContext$kotlinx_coroutines_core", "dispatchYield", "restore", "restore$kotlinx_coroutines_core", "shutdown", "timeout", "shutdown$kotlinx_coroutines_core", "usePrivateScheduler", "usePrivateScheduler$kotlinx_coroutines_core", "kotlinx-coroutines-core"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
public class SchedulerCoroutineDispatcher extends ExecutorCoroutineDispatcher {
|
||||
private final int corePoolSize;
|
||||
private CoroutineScheduler coroutineScheduler;
|
||||
private final long idleWorkerKeepAliveNs;
|
||||
private final int maxPoolSize;
|
||||
private final String schedulerName;
|
||||
|
||||
public SchedulerCoroutineDispatcher() {
|
||||
this(0, 0, 0L, null, 15, null);
|
||||
}
|
||||
|
||||
public /* synthetic */ SchedulerCoroutineDispatcher(int i, int i2, long j, String str, int i3, DefaultConstructorMarker defaultConstructorMarker) {
|
||||
this((i3 & 1) != 0 ? TasksKt.CORE_POOL_SIZE : i, (i3 & 2) != 0 ? TasksKt.MAX_POOL_SIZE : i2, (i3 & 4) != 0 ? TasksKt.IDLE_WORKER_KEEP_ALIVE_NS : j, (i3 & 8) != 0 ? "CoroutineScheduler" : str);
|
||||
}
|
||||
|
||||
public SchedulerCoroutineDispatcher(int i, int i2, long j, String str) {
|
||||
this.corePoolSize = i;
|
||||
this.maxPoolSize = i2;
|
||||
this.idleWorkerKeepAliveNs = j;
|
||||
this.schedulerName = str;
|
||||
this.coroutineScheduler = createScheduler();
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.ExecutorCoroutineDispatcher
|
||||
public Executor getExecutor() {
|
||||
return this.coroutineScheduler;
|
||||
}
|
||||
|
||||
private final CoroutineScheduler createScheduler() {
|
||||
return new CoroutineScheduler(this.corePoolSize, this.maxPoolSize, this.idleWorkerKeepAliveNs, this.schedulerName);
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.CoroutineDispatcher
|
||||
/* renamed from: dispatch */
|
||||
public void mo1907dispatch(CoroutineContext context, Runnable block) {
|
||||
CoroutineScheduler.dispatch$default(this.coroutineScheduler, block, null, false, 6, null);
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.CoroutineDispatcher
|
||||
public void dispatchYield(CoroutineContext context, Runnable block) {
|
||||
CoroutineScheduler.dispatch$default(this.coroutineScheduler, block, null, true, 2, null);
|
||||
}
|
||||
|
||||
public final void dispatchWithContext$kotlinx_coroutines_core(Runnable block, TaskContext context, boolean tailDispatch) {
|
||||
this.coroutineScheduler.dispatch(block, context, tailDispatch);
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.ExecutorCoroutineDispatcher, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() {
|
||||
this.coroutineScheduler.close();
|
||||
}
|
||||
|
||||
public final synchronized void usePrivateScheduler$kotlinx_coroutines_core() {
|
||||
this.coroutineScheduler.shutdown(1000L);
|
||||
this.coroutineScheduler = createScheduler();
|
||||
}
|
||||
|
||||
public final synchronized void shutdown$kotlinx_coroutines_core(long timeout) {
|
||||
this.coroutineScheduler.shutdown(timeout);
|
||||
}
|
||||
|
||||
public final void restore$kotlinx_coroutines_core() {
|
||||
usePrivateScheduler$kotlinx_coroutines_core();
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package kotlinx.coroutines.scheduling;
|
||||
|
||||
import kotlin.Metadata;
|
||||
|
||||
/* compiled from: Tasks.kt */
|
||||
@Metadata(d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\t\n\u0000\b \u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\b\u0010\u0003\u001a\u00020\u0004H&¨\u0006\u0005"}, d2 = {"Lkotlinx/coroutines/scheduling/SchedulerTimeSource;", "", "()V", "nanoTime", "", "kotlinx-coroutines-core"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class SchedulerTimeSource {
|
||||
public abstract long nanoTime();
|
||||
}
|
24
02-Easy5/E5/sources/kotlinx/coroutines/scheduling/Task.java
Normal file
24
02-Easy5/E5/sources/kotlinx/coroutines/scheduling/Task.java
Normal file
@ -0,0 +1,24 @@
|
||||
package kotlinx.coroutines.scheduling;
|
||||
|
||||
import kotlin.Metadata;
|
||||
|
||||
/* compiled from: Tasks.kt */
|
||||
@Metadata(d1 = {"\u0000&\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0003\b \u0018\u00002\u00060\u0001j\u0002`\u0002B\u0007\b\u0016¢\u0006\u0002\u0010\u0003B\u0015\u0012\u0006\u0010\u0004\u001a\u00020\u0005\u0012\u0006\u0010\u0006\u001a\u00020\u0007¢\u0006\u0002\u0010\bR\u0012\u0010\t\u001a\u00020\n8Æ\u0002¢\u0006\u0006\u001a\u0004\b\u000b\u0010\fR\u0012\u0010\u0004\u001a\u00020\u00058\u0006@\u0006X\u0087\u000e¢\u0006\u0002\n\u0000R\u0012\u0010\u0006\u001a\u00020\u00078\u0006@\u0006X\u0087\u000e¢\u0006\u0002\n\u0000¨\u0006\r"}, d2 = {"Lkotlinx/coroutines/scheduling/Task;", "Ljava/lang/Runnable;", "Lkotlinx/coroutines/Runnable;", "()V", "submissionTime", "", "taskContext", "Lkotlinx/coroutines/scheduling/TaskContext;", "(JLkotlinx/coroutines/scheduling/TaskContext;)V", "mode", "", "getMode", "()I", "kotlinx-coroutines-core"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class Task implements Runnable {
|
||||
public long submissionTime;
|
||||
public TaskContext taskContext;
|
||||
|
||||
public Task(long j, TaskContext taskContext) {
|
||||
this.submissionTime = j;
|
||||
this.taskContext = taskContext;
|
||||
}
|
||||
|
||||
public Task() {
|
||||
this(0L, TasksKt.NonBlockingContext);
|
||||
}
|
||||
|
||||
public final int getMode() {
|
||||
return this.taskContext.getTaskMode();
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package kotlinx.coroutines.scheduling;
|
||||
|
||||
import kotlin.Metadata;
|
||||
|
||||
/* compiled from: Tasks.kt */
|
||||
@Metadata(d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0000\b`\u0018\u00002\u00020\u0001J\b\u0010\u0006\u001a\u00020\u0007H&R\u0012\u0010\u0002\u001a\u00020\u0003X¦\u0004¢\u0006\u0006\u001a\u0004\b\u0004\u0010\u0005¨\u0006\b"}, d2 = {"Lkotlinx/coroutines/scheduling/TaskContext;", "", "taskMode", "", "getTaskMode", "()I", "afterTask", "", "kotlinx-coroutines-core"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
public interface TaskContext {
|
||||
void afterTask();
|
||||
|
||||
int getTaskMode();
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package kotlinx.coroutines.scheduling;
|
||||
|
||||
import kotlin.Metadata;
|
||||
|
||||
/* compiled from: Tasks.kt */
|
||||
@Metadata(d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0004\n\u0002\u0010\u0002\n\u0000\b\u0002\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\b\u0010\u0007\u001a\u00020\bH\u0016R\u0014\u0010\u0002\u001a\u00020\u0003X\u0096\u0004¢\u0006\b\n\u0000\u001a\u0004\b\u0005\u0010\u0006¨\u0006\t"}, d2 = {"Lkotlinx/coroutines/scheduling/TaskContextImpl;", "Lkotlinx/coroutines/scheduling/TaskContext;", "taskMode", "", "(I)V", "getTaskMode", "()I", "afterTask", "", "kotlinx-coroutines-core"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
final class TaskContextImpl implements TaskContext {
|
||||
private final int taskMode;
|
||||
|
||||
@Override // kotlinx.coroutines.scheduling.TaskContext
|
||||
public void afterTask() {
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.scheduling.TaskContext
|
||||
public int getTaskMode() {
|
||||
return this.taskMode;
|
||||
}
|
||||
|
||||
public TaskContextImpl(int i) {
|
||||
this.taskMode = i;
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package kotlinx.coroutines.scheduling;
|
||||
|
||||
import kotlin.Metadata;
|
||||
import kotlinx.coroutines.DebugStringsKt;
|
||||
|
||||
/* compiled from: Tasks.kt */
|
||||
@Metadata(d1 = {"\u0000.\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\b\u0000\u0018\u00002\u00020\u0001B!\u0012\n\u0010\u0002\u001a\u00060\u0003j\u0002`\u0004\u0012\u0006\u0010\u0005\u001a\u00020\u0006\u0012\u0006\u0010\u0007\u001a\u00020\b¢\u0006\u0002\u0010\tJ\b\u0010\n\u001a\u00020\u000bH\u0016J\b\u0010\f\u001a\u00020\rH\u0016R\u0014\u0010\u0002\u001a\u00060\u0003j\u0002`\u00048\u0006X\u0087\u0004¢\u0006\u0002\n\u0000¨\u0006\u000e"}, d2 = {"Lkotlinx/coroutines/scheduling/TaskImpl;", "Lkotlinx/coroutines/scheduling/Task;", "block", "Ljava/lang/Runnable;", "Lkotlinx/coroutines/Runnable;", "submissionTime", "", "taskContext", "Lkotlinx/coroutines/scheduling/TaskContext;", "(Ljava/lang/Runnable;JLkotlinx/coroutines/scheduling/TaskContext;)V", "run", "", "toString", "", "kotlinx-coroutines-core"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
public final class TaskImpl extends Task {
|
||||
public final Runnable block;
|
||||
|
||||
public TaskImpl(Runnable runnable, long j, TaskContext taskContext) {
|
||||
super(j, taskContext);
|
||||
this.block = runnable;
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
try {
|
||||
this.block.run();
|
||||
} finally {
|
||||
this.taskContext.afterTask();
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "Task[" + DebugStringsKt.getClassSimpleName(this.block) + '@' + DebugStringsKt.getHexAddress(this.block) + ", " + this.submissionTime + ", " + this.taskContext + ']';
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package kotlinx.coroutines.scheduling;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import kotlin.Metadata;
|
||||
import kotlin.ranges.RangesKt;
|
||||
import kotlinx.coroutines.internal.SystemPropsKt;
|
||||
import kotlinx.coroutines.internal.SystemPropsKt__SystemProps_commonKt;
|
||||
|
||||
/* compiled from: Tasks.kt */
|
||||
@Metadata(d1 = {"\u0000.\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\t\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\u0018\u0002\n\u0002\b\u0002\"\u0010\u0010\u0000\u001a\u00020\u00018\u0000X\u0081\u0004¢\u0006\u0002\n\u0000\"\u0010\u0010\u0002\u001a\u00020\u00038\u0000X\u0081\u0004¢\u0006\u0002\n\u0000\"\u0010\u0010\u0004\u001a\u00020\u00058\u0000X\u0081\u0004¢\u0006\u0002\n\u0000\"\u0010\u0010\u0006\u001a\u00020\u00078\u0000X\u0081\u0004¢\u0006\u0002\n\u0000\"\u0010\u0010\b\u001a\u00020\u00038\u0000X\u0081\u0004¢\u0006\u0002\n\u0000\"\u0010\u0010\t\u001a\u00020\u00018\u0000X\u0081\u0004¢\u0006\u0002\n\u0000\"\u000e\u0010\n\u001a\u00020\u0003X\u0080T¢\u0006\u0002\n\u0000\"\u000e\u0010\u000b\u001a\u00020\u0003X\u0080T¢\u0006\u0002\n\u0000\"\u0010\u0010\f\u001a\u00020\u00078\u0000X\u0081\u0004¢\u0006\u0002\n\u0000\"\u0012\u0010\r\u001a\u00020\u000e8\u0000@\u0000X\u0081\u000e¢\u0006\u0002\n\u0000\"\u0019\u0010\u000f\u001a\u00020\u0010*\u00020\u00118À\u0002X\u0080\u0004¢\u0006\u0006\u001a\u0004\b\u000f\u0010\u0012¨\u0006\u0013"}, d2 = {"BlockingContext", "Lkotlinx/coroutines/scheduling/TaskContext;", "CORE_POOL_SIZE", "", "DEFAULT_SCHEDULER_NAME", "", "IDLE_WORKER_KEEP_ALIVE_NS", "", "MAX_POOL_SIZE", "NonBlockingContext", "TASK_NON_BLOCKING", "TASK_PROBABLY_BLOCKING", "WORK_STEALING_TIME_RESOLUTION_NS", "schedulerTimeSource", "Lkotlinx/coroutines/scheduling/SchedulerTimeSource;", "isBlocking", "", "Lkotlinx/coroutines/scheduling/Task;", "(Lkotlinx/coroutines/scheduling/Task;)Z", "kotlinx-coroutines-core"}, k = 2, mv = {1, 8, 0}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
public final class TasksKt {
|
||||
public static final TaskContext BlockingContext;
|
||||
public static final int CORE_POOL_SIZE;
|
||||
public static final String DEFAULT_SCHEDULER_NAME = SystemPropsKt.systemProp("kotlinx.coroutines.scheduler.default.name", "DefaultDispatcher");
|
||||
public static final long IDLE_WORKER_KEEP_ALIVE_NS;
|
||||
public static final int MAX_POOL_SIZE;
|
||||
public static final TaskContext NonBlockingContext;
|
||||
public static final int TASK_NON_BLOCKING = 0;
|
||||
public static final int TASK_PROBABLY_BLOCKING = 1;
|
||||
public static final long WORK_STEALING_TIME_RESOLUTION_NS;
|
||||
public static SchedulerTimeSource schedulerTimeSource;
|
||||
|
||||
static {
|
||||
long systemProp$default;
|
||||
int systemProp$default2;
|
||||
int systemProp$default3;
|
||||
long systemProp$default4;
|
||||
systemProp$default = SystemPropsKt__SystemProps_commonKt.systemProp$default("kotlinx.coroutines.scheduler.resolution.ns", 100000L, 0L, 0L, 12, (Object) null);
|
||||
WORK_STEALING_TIME_RESOLUTION_NS = systemProp$default;
|
||||
systemProp$default2 = SystemPropsKt__SystemProps_commonKt.systemProp$default("kotlinx.coroutines.scheduler.core.pool.size", RangesKt.coerceAtLeast(SystemPropsKt.getAVAILABLE_PROCESSORS(), 2), 1, 0, 8, (Object) null);
|
||||
CORE_POOL_SIZE = systemProp$default2;
|
||||
systemProp$default3 = SystemPropsKt__SystemProps_commonKt.systemProp$default("kotlinx.coroutines.scheduler.max.pool.size", CoroutineScheduler.MAX_SUPPORTED_POOL_SIZE, 0, CoroutineScheduler.MAX_SUPPORTED_POOL_SIZE, 4, (Object) null);
|
||||
MAX_POOL_SIZE = systemProp$default3;
|
||||
TimeUnit timeUnit = TimeUnit.SECONDS;
|
||||
systemProp$default4 = SystemPropsKt__SystemProps_commonKt.systemProp$default("kotlinx.coroutines.scheduler.keep.alive.sec", 60L, 0L, 0L, 12, (Object) null);
|
||||
IDLE_WORKER_KEEP_ALIVE_NS = timeUnit.toNanos(systemProp$default4);
|
||||
schedulerTimeSource = NanoTimeSource.INSTANCE;
|
||||
NonBlockingContext = new TaskContextImpl(0);
|
||||
BlockingContext = new TaskContextImpl(1);
|
||||
}
|
||||
|
||||
public static final boolean isBlocking(Task task) {
|
||||
return task.taskContext.getTaskMode() == 1;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package kotlinx.coroutines.scheduling;
|
||||
|
||||
import kotlin.Metadata;
|
||||
import kotlin.coroutines.CoroutineContext;
|
||||
import kotlinx.coroutines.CoroutineDispatcher;
|
||||
import kotlinx.coroutines.internal.LimitedDispatcherKt;
|
||||
|
||||
/* compiled from: Dispatcher.kt */
|
||||
@Metadata(d1 = {"\u0000*\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\b\n\u0000\bÂ\u0002\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u001c\u0010\u0003\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u00062\n\u0010\u0007\u001a\u00060\bj\u0002`\tH\u0016J\u001c\u0010\n\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u00062\n\u0010\u0007\u001a\u00060\bj\u0002`\tH\u0017J\u0010\u0010\u000b\u001a\u00020\u00012\u0006\u0010\f\u001a\u00020\rH\u0017¨\u0006\u000e"}, d2 = {"Lkotlinx/coroutines/scheduling/UnlimitedIoScheduler;", "Lkotlinx/coroutines/CoroutineDispatcher;", "()V", "dispatch", "", "context", "Lkotlin/coroutines/CoroutineContext;", "block", "Ljava/lang/Runnable;", "Lkotlinx/coroutines/Runnable;", "dispatchYield", "limitedParallelism", "parallelism", "", "kotlinx-coroutines-core"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
final class UnlimitedIoScheduler extends CoroutineDispatcher {
|
||||
public static final UnlimitedIoScheduler INSTANCE = new UnlimitedIoScheduler();
|
||||
|
||||
private UnlimitedIoScheduler() {
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.CoroutineDispatcher
|
||||
public void dispatchYield(CoroutineContext context, Runnable block) {
|
||||
DefaultScheduler.INSTANCE.dispatchWithContext$kotlinx_coroutines_core(block, TasksKt.BlockingContext, true);
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.CoroutineDispatcher
|
||||
/* renamed from: dispatch */
|
||||
public void mo1907dispatch(CoroutineContext context, Runnable block) {
|
||||
DefaultScheduler.INSTANCE.dispatchWithContext$kotlinx_coroutines_core(block, TasksKt.BlockingContext, false);
|
||||
}
|
||||
|
||||
@Override // kotlinx.coroutines.CoroutineDispatcher
|
||||
public CoroutineDispatcher limitedParallelism(int parallelism) {
|
||||
LimitedDispatcherKt.checkParallelism(parallelism);
|
||||
return parallelism >= TasksKt.MAX_POOL_SIZE ? this : super.limitedParallelism(parallelism);
|
||||
}
|
||||
}
|
229
02-Easy5/E5/sources/kotlinx/coroutines/scheduling/WorkQueue.java
Normal file
229
02-Easy5/E5/sources/kotlinx/coroutines/scheduling/WorkQueue.java
Normal file
@ -0,0 +1,229 @@
|
||||
package kotlinx.coroutines.scheduling;
|
||||
|
||||
import androidx.concurrent.futures.AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0;
|
||||
import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
|
||||
import java.util.concurrent.atomic.AtomicReferenceArray;
|
||||
import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
|
||||
import kotlin.Metadata;
|
||||
import kotlin.jvm.Volatile;
|
||||
import kotlin.jvm.internal.Ref;
|
||||
import kotlinx.coroutines.DebugKt;
|
||||
import kotlinx.coroutines.channels.ChannelSegment$$ExternalSyntheticBackportWithForwarding0;
|
||||
|
||||
/* compiled from: WorkQueue.kt */
|
||||
@Metadata(d1 = {"\u0000X\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\n\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\b\u0000\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\u001a\u0010\u0012\u001a\u0004\u0018\u00010\u00072\u0006\u0010\u0013\u001a\u00020\u00072\b\b\u0002\u0010\u0014\u001a\u00020\u0015J\u0012\u0010\u0016\u001a\u0004\u0018\u00010\u00072\u0006\u0010\u0013\u001a\u00020\u0007H\u0002J\u000e\u0010\u0017\u001a\u00020\u00182\u0006\u0010\u0019\u001a\u00020\u001aJ\b\u0010\u001b\u001a\u0004\u0018\u00010\u0007J\b\u0010\u001c\u001a\u0004\u0018\u00010\u0007J\n\u0010\u001d\u001a\u0004\u0018\u00010\u0007H\u0002J\b\u0010\u001e\u001a\u0004\u0018\u00010\u0007J\u0010\u0010\u001f\u001a\u00020\u00152\u0006\u0010 \u001a\u00020\u001aH\u0002J\u0012\u0010!\u001a\u0004\u0018\u00010\u00072\u0006\u0010\"\u001a\u00020\u0015H\u0002J\u0016\u0010#\u001a\u0004\u0018\u00010\u00072\n\u0010$\u001a\u00060\tj\u0002`%H\u0002J\u001a\u0010&\u001a\u0004\u0018\u00010\u00072\u0006\u0010'\u001a\u00020\t2\u0006\u0010\"\u001a\u00020\u0015H\u0002J\"\u0010(\u001a\u00020)2\n\u0010$\u001a\u00060\tj\u0002`%2\u000e\u0010*\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u00070+J$\u0010,\u001a\u00020)2\n\u0010$\u001a\u00060\tj\u0002`%2\u000e\u0010*\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u00070+H\u0002J\u000e\u0010-\u001a\u00020\u0018*\u0004\u0018\u00010\u0007H\u0002R\t\u0010\u0003\u001a\u00020\u0004X\u0082\u0004R\u0016\u0010\u0005\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u00070\u0006X\u0082\u0004¢\u0006\u0002\n\u0000R\u0014\u0010\b\u001a\u00020\t8BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b\n\u0010\u000bR\t\u0010\f\u001a\u00020\u0004X\u0082\u0004R\u0011\u0010\r\u001a\n\u0012\u0006\u0012\u0004\u0018\u00010\u00070\u000eX\u0082\u0004R\t\u0010\u000f\u001a\u00020\u0004X\u0082\u0004R\u0014\u0010\u0010\u001a\u00020\t8@X\u0080\u0004¢\u0006\u0006\u001a\u0004\b\u0011\u0010\u000b¨\u0006."}, d2 = {"Lkotlinx/coroutines/scheduling/WorkQueue;", "", "()V", "blockingTasksInBuffer", "Lkotlinx/atomicfu/AtomicInt;", "buffer", "Ljava/util/concurrent/atomic/AtomicReferenceArray;", "Lkotlinx/coroutines/scheduling/Task;", "bufferSize", "", "getBufferSize", "()I", "consumerIndex", "lastScheduledTask", "Lkotlinx/atomicfu/AtomicRef;", "producerIndex", "size", "getSize$kotlinx_coroutines_core", "add", "task", "fair", "", "addLast", "offloadAllWorkTo", "", "globalQueue", "Lkotlinx/coroutines/scheduling/GlobalQueue;", "poll", "pollBlocking", "pollBuffer", "pollCpu", "pollTo", "queue", "pollWithExclusiveMode", "onlyBlocking", "stealWithExclusiveMode", "stealingMode", "Lkotlinx/coroutines/scheduling/StealingMode;", "tryExtractFromTheMiddle", "index", "trySteal", "", "stolenTaskRef", "Lkotlin/jvm/internal/Ref$ObjectRef;", "tryStealLastScheduled", "decrementIfBlocking", "kotlinx-coroutines-core"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
public final class WorkQueue {
|
||||
|
||||
@Volatile
|
||||
private volatile int blockingTasksInBuffer;
|
||||
private final AtomicReferenceArray<Task> buffer = new AtomicReferenceArray<>(128);
|
||||
|
||||
@Volatile
|
||||
private volatile int consumerIndex;
|
||||
|
||||
@Volatile
|
||||
private volatile Object lastScheduledTask;
|
||||
|
||||
@Volatile
|
||||
private volatile int producerIndex;
|
||||
private static final AtomicReferenceFieldUpdater lastScheduledTask$FU = AtomicReferenceFieldUpdater.newUpdater(WorkQueue.class, Object.class, "lastScheduledTask");
|
||||
private static final AtomicIntegerFieldUpdater producerIndex$FU = AtomicIntegerFieldUpdater.newUpdater(WorkQueue.class, "producerIndex");
|
||||
private static final AtomicIntegerFieldUpdater consumerIndex$FU = AtomicIntegerFieldUpdater.newUpdater(WorkQueue.class, "consumerIndex");
|
||||
private static final AtomicIntegerFieldUpdater blockingTasksInBuffer$FU = AtomicIntegerFieldUpdater.newUpdater(WorkQueue.class, "blockingTasksInBuffer");
|
||||
|
||||
private final int getBufferSize() {
|
||||
return producerIndex$FU.get(this) - consumerIndex$FU.get(this);
|
||||
}
|
||||
|
||||
public final int getSize$kotlinx_coroutines_core() {
|
||||
return lastScheduledTask$FU.get(this) != null ? getBufferSize() + 1 : getBufferSize();
|
||||
}
|
||||
|
||||
public final Task poll() {
|
||||
Task task = (Task) lastScheduledTask$FU.getAndSet(this, null);
|
||||
return task == null ? pollBuffer() : task;
|
||||
}
|
||||
|
||||
public static /* synthetic */ Task add$default(WorkQueue workQueue, Task task, boolean z, int i, Object obj) {
|
||||
if ((i & 2) != 0) {
|
||||
z = false;
|
||||
}
|
||||
return workQueue.add(task, z);
|
||||
}
|
||||
|
||||
public final Task add(Task task, boolean fair) {
|
||||
if (fair) {
|
||||
return addLast(task);
|
||||
}
|
||||
Task task2 = (Task) lastScheduledTask$FU.getAndSet(this, task);
|
||||
if (task2 == null) {
|
||||
return null;
|
||||
}
|
||||
return addLast(task2);
|
||||
}
|
||||
|
||||
private final Task addLast(Task task) {
|
||||
if (getBufferSize() == 127) {
|
||||
return task;
|
||||
}
|
||||
if (task.taskContext.getTaskMode() == 1) {
|
||||
blockingTasksInBuffer$FU.incrementAndGet(this);
|
||||
}
|
||||
int i = producerIndex$FU.get(this) & WorkQueueKt.MASK;
|
||||
while (this.buffer.get(i) != null) {
|
||||
Thread.yield();
|
||||
}
|
||||
this.buffer.lazySet(i, task);
|
||||
producerIndex$FU.incrementAndGet(this);
|
||||
return null;
|
||||
}
|
||||
|
||||
/* JADX WARN: Multi-variable type inference failed */
|
||||
public final long trySteal(int stealingMode, Ref.ObjectRef<Task> stolenTaskRef) {
|
||||
T t;
|
||||
if (stealingMode == 3) {
|
||||
t = pollBuffer();
|
||||
} else {
|
||||
t = stealWithExclusiveMode(stealingMode);
|
||||
}
|
||||
if (t != 0) {
|
||||
stolenTaskRef.element = t;
|
||||
return -1L;
|
||||
}
|
||||
return tryStealLastScheduled(stealingMode, stolenTaskRef);
|
||||
}
|
||||
|
||||
private final Task stealWithExclusiveMode(int stealingMode) {
|
||||
int i = consumerIndex$FU.get(this);
|
||||
int i2 = producerIndex$FU.get(this);
|
||||
boolean z = stealingMode == 1;
|
||||
while (i != i2) {
|
||||
if (z && blockingTasksInBuffer$FU.get(this) == 0) {
|
||||
return null;
|
||||
}
|
||||
int i3 = i + 1;
|
||||
Task tryExtractFromTheMiddle = tryExtractFromTheMiddle(i, z);
|
||||
if (tryExtractFromTheMiddle != null) {
|
||||
return tryExtractFromTheMiddle;
|
||||
}
|
||||
i = i3;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public final Task pollBlocking() {
|
||||
return pollWithExclusiveMode(true);
|
||||
}
|
||||
|
||||
public final Task pollCpu() {
|
||||
return pollWithExclusiveMode(false);
|
||||
}
|
||||
|
||||
private final Task pollWithExclusiveMode(boolean onlyBlocking) {
|
||||
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater;
|
||||
Task task;
|
||||
do {
|
||||
atomicReferenceFieldUpdater = lastScheduledTask$FU;
|
||||
task = (Task) atomicReferenceFieldUpdater.get(this);
|
||||
if (task != null) {
|
||||
if ((task.taskContext.getTaskMode() == 1) == onlyBlocking) {
|
||||
}
|
||||
}
|
||||
int i = consumerIndex$FU.get(this);
|
||||
int i2 = producerIndex$FU.get(this);
|
||||
while (i != i2) {
|
||||
if (onlyBlocking && blockingTasksInBuffer$FU.get(this) == 0) {
|
||||
return null;
|
||||
}
|
||||
i2--;
|
||||
Task tryExtractFromTheMiddle = tryExtractFromTheMiddle(i2, onlyBlocking);
|
||||
if (tryExtractFromTheMiddle != null) {
|
||||
return tryExtractFromTheMiddle;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} while (!AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(atomicReferenceFieldUpdater, this, task, null));
|
||||
return task;
|
||||
}
|
||||
|
||||
private final Task tryExtractFromTheMiddle(int index, boolean onlyBlocking) {
|
||||
int i = index & WorkQueueKt.MASK;
|
||||
Task task = this.buffer.get(i);
|
||||
if (task != null) {
|
||||
if ((task.taskContext.getTaskMode() == 1) == onlyBlocking && ChannelSegment$$ExternalSyntheticBackportWithForwarding0.m(this.buffer, i, task, null)) {
|
||||
if (onlyBlocking) {
|
||||
blockingTasksInBuffer$FU.decrementAndGet(this);
|
||||
}
|
||||
return task;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public final void offloadAllWorkTo(GlobalQueue globalQueue) {
|
||||
Task task = (Task) lastScheduledTask$FU.getAndSet(this, null);
|
||||
if (task != null) {
|
||||
globalQueue.addLast(task);
|
||||
}
|
||||
while (pollTo(globalQueue)) {
|
||||
}
|
||||
}
|
||||
|
||||
/* JADX WARN: Type inference failed for: r1v1, types: [T, java.lang.Object, kotlinx.coroutines.scheduling.Task] */
|
||||
private final long tryStealLastScheduled(int stealingMode, Ref.ObjectRef<Task> stolenTaskRef) {
|
||||
AtomicReferenceFieldUpdater atomicReferenceFieldUpdater;
|
||||
?? r1;
|
||||
do {
|
||||
atomicReferenceFieldUpdater = lastScheduledTask$FU;
|
||||
r1 = (Task) atomicReferenceFieldUpdater.get(this);
|
||||
if (r1 == 0) {
|
||||
return -2L;
|
||||
}
|
||||
if (((r1.taskContext.getTaskMode() != 1 ? 2 : 1) & stealingMode) == 0) {
|
||||
return -2L;
|
||||
}
|
||||
long nanoTime = TasksKt.schedulerTimeSource.nanoTime() - r1.submissionTime;
|
||||
if (nanoTime < TasksKt.WORK_STEALING_TIME_RESOLUTION_NS) {
|
||||
return TasksKt.WORK_STEALING_TIME_RESOLUTION_NS - nanoTime;
|
||||
}
|
||||
} while (!AbstractResolvableFuture$SafeAtomicHelper$$ExternalSyntheticBackportWithForwarding0.m(atomicReferenceFieldUpdater, this, r1, null));
|
||||
stolenTaskRef.element = r1;
|
||||
return -1L;
|
||||
}
|
||||
|
||||
private final boolean pollTo(GlobalQueue queue) {
|
||||
Task pollBuffer = pollBuffer();
|
||||
if (pollBuffer == null) {
|
||||
return false;
|
||||
}
|
||||
queue.addLast(pollBuffer);
|
||||
return true;
|
||||
}
|
||||
|
||||
private final Task pollBuffer() {
|
||||
Task andSet;
|
||||
while (true) {
|
||||
AtomicIntegerFieldUpdater atomicIntegerFieldUpdater = consumerIndex$FU;
|
||||
int i = atomicIntegerFieldUpdater.get(this);
|
||||
if (i - producerIndex$FU.get(this) == 0) {
|
||||
return null;
|
||||
}
|
||||
int i2 = i & WorkQueueKt.MASK;
|
||||
if (atomicIntegerFieldUpdater.compareAndSet(this, i, i + 1) && (andSet = this.buffer.getAndSet(i2, null)) != null) {
|
||||
decrementIfBlocking(andSet);
|
||||
return andSet;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final void decrementIfBlocking(Task task) {
|
||||
if (task == null || task.taskContext.getTaskMode() != 1) {
|
||||
return;
|
||||
}
|
||||
int decrementAndGet = blockingTasksInBuffer$FU.decrementAndGet(this);
|
||||
if (DebugKt.getASSERTIONS_ENABLED() && decrementAndGet < 0) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package kotlinx.coroutines.scheduling;
|
||||
|
||||
import kotlin.Metadata;
|
||||
|
||||
/* compiled from: WorkQueue.kt */
|
||||
@Metadata(d1 = {"\u0000 \n\u0000\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0010\t\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\"\u000e\u0010\u0000\u001a\u00020\u0001X\u0080T¢\u0006\u0002\n\u0000\"\u000e\u0010\u0002\u001a\u00020\u0001X\u0080T¢\u0006\u0002\n\u0000\"\u000e\u0010\u0003\u001a\u00020\u0001X\u0080T¢\u0006\u0002\n\u0000\"\u000e\u0010\u0004\u001a\u00020\u0005X\u0080T¢\u0006\u0002\n\u0000\"\u0012\u0010\u0006\u001a\u00060\u0001j\u0002`\u0007X\u0080T¢\u0006\u0002\n\u0000\"\u0012\u0010\b\u001a\u00060\u0001j\u0002`\u0007X\u0080T¢\u0006\u0002\n\u0000\"\u0012\u0010\t\u001a\u00060\u0001j\u0002`\u0007X\u0080T¢\u0006\u0002\n\u0000\"\u000e\u0010\n\u001a\u00020\u0005X\u0080T¢\u0006\u0002\n\u0000\"\u0019\u0010\u000b\u001a\u00020\u0001*\u00020\f8À\u0002X\u0080\u0004¢\u0006\u0006\u001a\u0004\b\r\u0010\u000e*\f\b\u0000\u0010\u000f\"\u00020\u00012\u00020\u0001¨\u0006\u0010"}, d2 = {"BUFFER_CAPACITY", "", "BUFFER_CAPACITY_BASE", "MASK", "NOTHING_TO_STEAL", "", "STEAL_ANY", "Lkotlinx/coroutines/scheduling/StealingMode;", "STEAL_BLOCKING_ONLY", "STEAL_CPU_ONLY", "TASK_STOLEN", "maskForStealingMode", "Lkotlinx/coroutines/scheduling/Task;", "getMaskForStealingMode", "(Lkotlinx/coroutines/scheduling/Task;)I", "StealingMode", "kotlinx-coroutines-core"}, k = 2, mv = {1, 8, 0}, xi = 48)
|
||||
/* loaded from: classes.dex */
|
||||
public final class WorkQueueKt {
|
||||
public static final int BUFFER_CAPACITY = 128;
|
||||
public static final int BUFFER_CAPACITY_BASE = 7;
|
||||
public static final int MASK = 127;
|
||||
public static final long NOTHING_TO_STEAL = -2;
|
||||
public static final int STEAL_ANY = 3;
|
||||
public static final int STEAL_BLOCKING_ONLY = 1;
|
||||
public static final int STEAL_CPU_ONLY = 2;
|
||||
public static final long TASK_STOLEN = -1;
|
||||
|
||||
public static final int getMaskForStealingMode(Task task) {
|
||||
return task.taskContext.getTaskMode() == 1 ? 1 : 2;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user