mirror of
https://github.com/Pinball3D/Rabbit-R1.git
synced 2024-12-24 08:02:37 -06:00
123 lines
5.9 KiB
Java
123 lines
5.9 KiB
Java
|
package kotlinx.coroutines;
|
||
|
|
||
|
import kotlin.Metadata;
|
||
|
import kotlin.collections.ArrayDeque;
|
||
|
import kotlinx.coroutines.internal.LimitedDispatcherKt;
|
||
|
|
||
|
/* compiled from: EventLoop.common.kt */
|
||
|
@Metadata(d1 = {"\u00008\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0002\b\u0005\n\u0002\u0010\t\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0002\b\u0007\n\u0002\u0010\b\n\u0002\b\u0005\b \u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\u0010\u0010\u0012\u001a\u00020\u00132\b\b\u0002\u0010\u0014\u001a\u00020\u0004J\u0010\u0010\u0015\u001a\u00020\n2\u0006\u0010\u0014\u001a\u00020\u0004H\u0002J\u0012\u0010\u0016\u001a\u00020\u00132\n\u0010\u0017\u001a\u0006\u0012\u0002\b\u00030\u0010J\u0010\u0010\u0018\u001a\u00020\u00132\b\b\u0002\u0010\u0014\u001a\u00020\u0004J\u000e\u0010\u0019\u001a\u00020\u00012\u0006\u0010\u001a\u001a\u00020\u001bJ\b\u0010\u001c\u001a\u00020\nH\u0016J\u0006\u0010\u001d\u001a\u00020\u0004J\b\u0010\u001e\u001a\u00020\u0004H\u0016J\b\u0010\u001f\u001a\u00020\u0013H\u0016R\u0011\u0010\u0003\u001a\u00020\u00048F¢\u0006\u0006\u001a\u0004\b\u0003\u0010\u0005R\u0014\u0010\u0006\u001a\u00020\u00048TX\u0094\u0004¢\u0006\u0006\u001a\u0004\b\u0006\u0010\u0005R\u0011\u0010\u0007\u001a\u00020\u00048F¢\u0006\u0006\u001a\u0004\b\u0007\u0010\u0005R\u0011\u0010\b\u001a\u00020\u00048F¢\u0006\u0006\u001a\u0004\b\b\u0010\u0005R\u0014\u0010\t\u001a\u00020\n8TX\u0094\u0004¢\u0006\u0006\u001a\u0004\b\u000b\u0010\fR\u000e\u0010\r\u001a\u00020\u0004X\u0082\u000e¢\u0006\u0002\n\u0000R\u001a\u0010\u000e\u001a\u000e\u0012\b\u0012\u0006\u0012\u0002\b\u00030\u0010\u0018\u00010\u000fX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0011\u001a\u00020\nX\u0082\u000e¢\u0006\u0002\n\u0000¨\u0006 "}, d2 = {"Lkotlinx/coroutines/EventLoop;", "Lkotlinx/coroutines/CoroutineDispatcher;", "()V", "isActive", "", "()Z", "isEmpty", "isUnconfinedLoopActive", "isUnconfinedQueueEmpty", "nextTime", "", "getNextTime", "()J", "shared", "unconfinedQueue", "Lkotlin/collections/ArrayDeque;", "Lkotlinx/coroutines/DispatchedTask;", "useCount", "decrementUseCount", "", "unconfined", "delta", "dispatchUnconfined", "task", "incrementUseCount", "limitedParallelism", "parallelism", "", "processNextEvent", "processUnconfinedEvent", "shouldBeProcessedFromContext", "shutdown", "kotlinx-coroutines-core"}, k = 1, mv = {1, 8, 0}, xi = 48)
|
||
|
/* loaded from: classes3.dex */
|
||
|
public abstract class EventLoop extends CoroutineDispatcher {
|
||
|
private boolean shared;
|
||
|
private ArrayDeque<DispatchedTask<?>> unconfinedQueue;
|
||
|
private long useCount;
|
||
|
|
||
|
private final long delta(boolean unconfined) {
|
||
|
return unconfined ? 4294967296L : 1L;
|
||
|
}
|
||
|
|
||
|
public final boolean isActive() {
|
||
|
return this.useCount > 0;
|
||
|
}
|
||
|
|
||
|
public boolean shouldBeProcessedFromContext() {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
public void shutdown() {
|
||
|
}
|
||
|
|
||
|
public long processNextEvent() {
|
||
|
return !processUnconfinedEvent() ? Long.MAX_VALUE : 0L;
|
||
|
}
|
||
|
|
||
|
protected boolean isEmpty() {
|
||
|
return isUnconfinedQueueEmpty();
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: protected */
|
||
|
public long getNextTime() {
|
||
|
ArrayDeque<DispatchedTask<?>> arrayDeque = this.unconfinedQueue;
|
||
|
return (arrayDeque == null || arrayDeque.isEmpty()) ? Long.MAX_VALUE : 0L;
|
||
|
}
|
||
|
|
||
|
public final boolean processUnconfinedEvent() {
|
||
|
DispatchedTask<?> removeFirstOrNull;
|
||
|
ArrayDeque<DispatchedTask<?>> arrayDeque = this.unconfinedQueue;
|
||
|
if (arrayDeque == null || (removeFirstOrNull = arrayDeque.removeFirstOrNull()) == null) {
|
||
|
return false;
|
||
|
}
|
||
|
removeFirstOrNull.run();
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public final void dispatchUnconfined(DispatchedTask<?> task) {
|
||
|
ArrayDeque<DispatchedTask<?>> arrayDeque = this.unconfinedQueue;
|
||
|
if (arrayDeque == null) {
|
||
|
arrayDeque = new ArrayDeque<>();
|
||
|
this.unconfinedQueue = arrayDeque;
|
||
|
}
|
||
|
arrayDeque.addLast(task);
|
||
|
}
|
||
|
|
||
|
public final boolean isUnconfinedLoopActive() {
|
||
|
return this.useCount >= delta(true);
|
||
|
}
|
||
|
|
||
|
public final boolean isUnconfinedQueueEmpty() {
|
||
|
ArrayDeque<DispatchedTask<?>> arrayDeque = this.unconfinedQueue;
|
||
|
if (arrayDeque != null) {
|
||
|
return arrayDeque.isEmpty();
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ void incrementUseCount$default(EventLoop eventLoop, boolean z, int i, Object obj) {
|
||
|
if (obj != null) {
|
||
|
throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: incrementUseCount");
|
||
|
}
|
||
|
if ((i & 1) != 0) {
|
||
|
z = false;
|
||
|
}
|
||
|
eventLoop.incrementUseCount(z);
|
||
|
}
|
||
|
|
||
|
public final void incrementUseCount(boolean unconfined) {
|
||
|
this.useCount += delta(unconfined);
|
||
|
if (unconfined) {
|
||
|
return;
|
||
|
}
|
||
|
this.shared = true;
|
||
|
}
|
||
|
|
||
|
public static /* synthetic */ void decrementUseCount$default(EventLoop eventLoop, boolean z, int i, Object obj) {
|
||
|
if (obj != null) {
|
||
|
throw new UnsupportedOperationException("Super calls with default arguments not supported in this target, function: decrementUseCount");
|
||
|
}
|
||
|
if ((i & 1) != 0) {
|
||
|
z = false;
|
||
|
}
|
||
|
eventLoop.decrementUseCount(z);
|
||
|
}
|
||
|
|
||
|
public final void decrementUseCount(boolean unconfined) {
|
||
|
long delta = this.useCount - delta(unconfined);
|
||
|
this.useCount = delta;
|
||
|
if (delta > 0) {
|
||
|
return;
|
||
|
}
|
||
|
if (DebugKt.getASSERTIONS_ENABLED() && this.useCount != 0) {
|
||
|
throw new AssertionError();
|
||
|
}
|
||
|
if (this.shared) {
|
||
|
shutdown();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // kotlinx.coroutines.CoroutineDispatcher
|
||
|
public final CoroutineDispatcher limitedParallelism(int parallelism) {
|
||
|
LimitedDispatcherKt.checkParallelism(parallelism);
|
||
|
return this;
|
||
|
}
|
||
|
}
|