- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
96 lines
2.9 KiB
Java
96 lines
2.9 KiB
Java
package androidx.lifecycle;
|
|
|
|
import androidx.annotation.AnyThread;
|
|
import androidx.annotation.MainThread;
|
|
import java.util.ArrayDeque;
|
|
import java.util.Queue;
|
|
import kotlin.coroutines.CoroutineContext;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlinx.coroutines.Dispatchers;
|
|
import kotlinx.coroutines.MainCoroutineDispatcher;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class DispatchQueue {
|
|
private boolean finished;
|
|
private boolean isDraining;
|
|
private boolean paused = true;
|
|
private final Queue<Runnable> queue = new ArrayDeque();
|
|
|
|
@MainThread
|
|
public final boolean canRun() {
|
|
return this.finished || !this.paused;
|
|
}
|
|
|
|
@MainThread
|
|
public final void pause() {
|
|
this.paused = true;
|
|
}
|
|
|
|
@MainThread
|
|
public final void resume() {
|
|
if (this.paused) {
|
|
if (!(!this.finished)) {
|
|
throw new IllegalStateException("Cannot resume a finished dispatcher".toString());
|
|
}
|
|
this.paused = false;
|
|
drainQueue();
|
|
}
|
|
}
|
|
|
|
@MainThread
|
|
public final void finish() {
|
|
this.finished = true;
|
|
drainQueue();
|
|
}
|
|
|
|
@MainThread
|
|
public final void drainQueue() {
|
|
if (this.isDraining) {
|
|
return;
|
|
}
|
|
try {
|
|
this.isDraining = true;
|
|
while ((!this.queue.isEmpty()) && canRun()) {
|
|
Runnable poll = this.queue.poll();
|
|
if (poll != null) {
|
|
poll.run();
|
|
}
|
|
}
|
|
} finally {
|
|
this.isDraining = false;
|
|
}
|
|
}
|
|
|
|
@AnyThread
|
|
public final void dispatchAndEnqueue(CoroutineContext context, final Runnable runnable) {
|
|
Intrinsics.checkNotNullParameter(context, "context");
|
|
Intrinsics.checkNotNullParameter(runnable, "runnable");
|
|
MainCoroutineDispatcher immediate = Dispatchers.getMain().getImmediate();
|
|
if (immediate.isDispatchNeeded(context) || canRun()) {
|
|
immediate.mo4148dispatch(context, new Runnable() { // from class: androidx.lifecycle.DispatchQueue$$ExternalSyntheticLambda0
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
DispatchQueue.dispatchAndEnqueue$lambda$2$lambda$1(DispatchQueue.this, runnable);
|
|
}
|
|
});
|
|
} else {
|
|
enqueue(runnable);
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public static final void dispatchAndEnqueue$lambda$2$lambda$1(DispatchQueue this$0, Runnable runnable) {
|
|
Intrinsics.checkNotNullParameter(this$0, "this$0");
|
|
Intrinsics.checkNotNullParameter(runnable, "$runnable");
|
|
this$0.enqueue(runnable);
|
|
}
|
|
|
|
@MainThread
|
|
private final void enqueue(Runnable runnable) {
|
|
if (!this.queue.offer(runnable)) {
|
|
throw new IllegalStateException("cannot enqueue any more runnables".toString());
|
|
}
|
|
drainQueue();
|
|
}
|
|
}
|