Files
rr3-apk/decompiled-community/sources/androidx/work/impl/utils/SerialExecutorImpl.java
Daniel Elliott c080f0d97f Add Discord community version (64-bit only)
- 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
2026-02-18 15:48:36 -08:00

86 lines
2.4 KiB
Java

package androidx.work.impl.utils;
import androidx.annotation.GuardedBy;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import androidx.work.impl.utils.taskexecutor.SerialExecutor;
import java.util.ArrayDeque;
import java.util.concurrent.Executor;
/* loaded from: classes.dex */
public class SerialExecutorImpl implements SerialExecutor {
@GuardedBy("mLock")
private Runnable mActive;
private final Executor mExecutor;
private final ArrayDeque<Task> mTasks = new ArrayDeque<>();
final Object mLock = new Object();
@NonNull
@VisibleForTesting
public Executor getDelegatedExecutor() {
return this.mExecutor;
}
public SerialExecutorImpl(@NonNull Executor executor) {
this.mExecutor = executor;
}
@Override // java.util.concurrent.Executor
public void execute(@NonNull Runnable runnable) {
synchronized (this.mLock) {
try {
this.mTasks.add(new Task(this, runnable));
if (this.mActive == null) {
scheduleNext();
}
} catch (Throwable th) {
throw th;
}
}
}
@GuardedBy("mLock")
public void scheduleNext() {
Task poll = this.mTasks.poll();
this.mActive = poll;
if (poll != null) {
this.mExecutor.execute(poll);
}
}
@Override // androidx.work.impl.utils.taskexecutor.SerialExecutor
public boolean hasPendingTasks() {
boolean z;
synchronized (this.mLock) {
z = !this.mTasks.isEmpty();
}
return z;
}
public static class Task implements Runnable {
final Runnable mRunnable;
final SerialExecutorImpl mSerialExecutor;
public Task(@NonNull SerialExecutorImpl serialExecutorImpl, @NonNull Runnable runnable) {
this.mSerialExecutor = serialExecutorImpl;
this.mRunnable = runnable;
}
@Override // java.lang.Runnable
public void run() {
try {
this.mRunnable.run();
synchronized (this.mSerialExecutor.mLock) {
this.mSerialExecutor.scheduleNext();
}
} catch (Throwable th) {
synchronized (this.mSerialExecutor.mLock) {
this.mSerialExecutor.scheduleNext();
throw th;
}
}
}
}
}