47 lines
1.6 KiB
Java
47 lines
1.6 KiB
Java
package com.google.firebase.firestore.util;
|
|
|
|
import java.util.concurrent.Executor;
|
|
import java.util.concurrent.Semaphore;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class BackgroundQueue implements Executor {
|
|
private Semaphore completedTasks = new Semaphore(0);
|
|
private int pendingTaskCount = 0;
|
|
|
|
@Override // java.util.concurrent.Executor
|
|
public void execute(final Runnable runnable) {
|
|
this.pendingTaskCount++;
|
|
Executors.BACKGROUND_EXECUTOR.execute(new Runnable(this, runnable) { // from class: com.google.firebase.firestore.util.BackgroundQueue$$ExternalSyntheticLambda0
|
|
public final BackgroundQueue f$0;
|
|
public final Runnable f$1;
|
|
|
|
@Override // java.lang.Runnable
|
|
public final void run() {
|
|
this.f$0.m256x97f26df8(this.f$1);
|
|
}
|
|
|
|
{
|
|
this.f$0 = this;
|
|
this.f$1 = runnable;
|
|
}
|
|
});
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
/* renamed from: lambda$execute$0$com-google-firebase-firestore-util-BackgroundQueue, reason: not valid java name */
|
|
public /* synthetic */ void m256x97f26df8(Runnable runnable) {
|
|
runnable.run();
|
|
this.completedTasks.release();
|
|
}
|
|
|
|
public void drain() {
|
|
try {
|
|
this.completedTasks.acquire(this.pendingTaskCount);
|
|
this.pendingTaskCount = 0;
|
|
} catch (InterruptedException e) {
|
|
Thread.currentThread().interrupt();
|
|
Assert.fail("Interrupted while waiting for background task", e);
|
|
}
|
|
}
|
|
}
|