package androidx.room; import java.util.ArrayDeque; import java.util.concurrent.Executor; import kotlin.Unit; import kotlin.jvm.internal.Intrinsics; import kotlin.jvm.internal.SourceDebugExtension; @SourceDebugExtension({"SMAP\nTransactionExecutor.kt\nKotlin\n*S Kotlin\n*F\n+ 1 TransactionExecutor.kt\nandroidx/room/TransactionExecutor\n+ 2 fake.kt\nkotlin/jvm/internal/FakeKt\n*L\n1#1,55:1\n1#2:56\n*E\n"}) /* loaded from: classes.dex */ public final class TransactionExecutor implements Executor { private Runnable active; private final Executor executor; private final Object syncLock; private final ArrayDeque tasks; public TransactionExecutor(Executor executor) { Intrinsics.checkNotNullParameter(executor, "executor"); this.executor = executor; this.tasks = new ArrayDeque<>(); this.syncLock = new Object(); } @Override // java.util.concurrent.Executor public void execute(final Runnable command) { Intrinsics.checkNotNullParameter(command, "command"); synchronized (this.syncLock) { try { this.tasks.offer(new Runnable() { // from class: androidx.room.TransactionExecutor$$ExternalSyntheticLambda0 @Override // java.lang.Runnable public final void run() { TransactionExecutor.execute$lambda$1$lambda$0(command, this); } }); if (this.active == null) { scheduleNext(); } Unit unit = Unit.INSTANCE; } catch (Throwable th) { throw th; } } } /* JADX INFO: Access modifiers changed from: private */ public static final void execute$lambda$1$lambda$0(Runnable command, TransactionExecutor this$0) { Intrinsics.checkNotNullParameter(command, "$command"); Intrinsics.checkNotNullParameter(this$0, "this$0"); try { command.run(); } finally { this$0.scheduleNext(); } } public final void scheduleNext() { synchronized (this.syncLock) { try { Runnable poll = this.tasks.poll(); Runnable runnable = poll; this.active = runnable; if (poll != null) { this.executor.execute(runnable); } Unit unit = Unit.INSTANCE; } catch (Throwable th) { throw th; } } } }