2021-07-24 02:37:17 +00:00
|
|
|
package androidx.lifecycle;
|
|
|
|
|
|
|
|
import androidx.annotation.MainThread;
|
2021-12-17 21:59:34 +00:00
|
|
|
import b.i.a.f.e.o.f;
|
2021-11-02 06:38:17 +00:00
|
|
|
import d0.z.d.m;
|
2021-07-24 02:37:17 +00:00
|
|
|
import kotlin.Unit;
|
|
|
|
import kotlin.coroutines.Continuation;
|
|
|
|
import kotlin.jvm.functions.Function0;
|
|
|
|
import kotlin.jvm.functions.Function2;
|
|
|
|
import kotlinx.coroutines.CoroutineDispatcher;
|
|
|
|
import kotlinx.coroutines.CoroutineScope;
|
|
|
|
import kotlinx.coroutines.Job;
|
2021-11-02 06:38:17 +00:00
|
|
|
import s.a.a.n;
|
2021-12-02 18:53:44 +00:00
|
|
|
import s.a.k0;
|
2021-07-24 02:37:17 +00:00
|
|
|
/* compiled from: CoroutineLiveData.kt */
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes.dex */
|
2021-07-24 02:37:17 +00:00
|
|
|
public final class BlockRunner<T> {
|
|
|
|
private final Function2<LiveDataScope<T>, Continuation<? super Unit>, Object> block;
|
|
|
|
private Job cancellationJob;
|
|
|
|
private final CoroutineLiveData<T> liveData;
|
|
|
|
private final Function0<Unit> onDone;
|
|
|
|
private Job runningJob;
|
|
|
|
private final CoroutineScope scope;
|
|
|
|
private final long timeoutInMs;
|
|
|
|
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
|
|
public BlockRunner(CoroutineLiveData<T> coroutineLiveData, Function2<? super LiveDataScope<T>, ? super Continuation<? super Unit>, ? extends Object> function2, long j, CoroutineScope coroutineScope, Function0<Unit> function0) {
|
|
|
|
m.checkNotNullParameter(coroutineLiveData, "liveData");
|
|
|
|
m.checkNotNullParameter(function2, "block");
|
|
|
|
m.checkNotNullParameter(coroutineScope, "scope");
|
|
|
|
m.checkNotNullParameter(function0, "onDone");
|
|
|
|
this.liveData = coroutineLiveData;
|
|
|
|
this.block = function2;
|
|
|
|
this.timeoutInMs = j;
|
|
|
|
this.scope = coroutineScope;
|
|
|
|
this.onDone = function0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ Function2 access$getBlock$p(BlockRunner blockRunner) {
|
|
|
|
return blockRunner.block;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ CoroutineLiveData access$getLiveData$p(BlockRunner blockRunner) {
|
|
|
|
return blockRunner.liveData;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ Function0 access$getOnDone$p(BlockRunner blockRunner) {
|
|
|
|
return blockRunner.onDone;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ Job access$getRunningJob$p(BlockRunner blockRunner) {
|
|
|
|
return blockRunner.runningJob;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ long access$getTimeoutInMs$p(BlockRunner blockRunner) {
|
|
|
|
return blockRunner.timeoutInMs;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$setRunningJob$p(BlockRunner blockRunner, Job job) {
|
|
|
|
blockRunner.runningJob = job;
|
|
|
|
}
|
|
|
|
|
|
|
|
@MainThread
|
|
|
|
public final void cancel() {
|
|
|
|
if (this.cancellationJob == null) {
|
|
|
|
CoroutineScope coroutineScope = this.scope;
|
2021-12-02 18:53:44 +00:00
|
|
|
CoroutineDispatcher coroutineDispatcher = k0.a;
|
2022-04-04 09:20:14 +00:00
|
|
|
this.cancellationJob = f.H0(coroutineScope, n.f3824b.H(), null, new BlockRunner$cancel$1(this, null), 2, null);
|
2021-07-24 02:37:17 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
throw new IllegalStateException("Cancel call cannot happen without a maybeRun".toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
@MainThread
|
|
|
|
public final void maybeRun() {
|
|
|
|
Job job = this.cancellationJob;
|
|
|
|
if (job != null) {
|
2022-01-13 08:07:50 +00:00
|
|
|
f.t(job, null, 1, null);
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
this.cancellationJob = null;
|
|
|
|
if (this.runningJob == null) {
|
2022-01-13 08:07:50 +00:00
|
|
|
this.runningJob = f.H0(this.scope, null, null, new BlockRunner$maybeRun$1(this, null), 3, null);
|
2021-07-24 02:37:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|