Files

129 lines
9.4 KiB
Java
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package kotlinx.coroutines;
import com.google.firebase.remoteconfig.RemoteConfigConstants;
import java.util.concurrent.CancellationException;
import kotlin.Metadata;
import kotlin.PublishedApi;
import kotlin.Result;
import kotlin.ResultKt;
import kotlin.Unit;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.CoroutineContext;
import kotlin.jvm.JvmField;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
import kotlinx.coroutines.internal.DispatchedContinuation;
import kotlinx.coroutines.internal.ThreadContextKt;
import kotlinx.coroutines.scheduling.Task;
import kotlinx.coroutines.scheduling.TaskContext;
@Metadata(d1 = {"\u00004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u0002\n\u0000\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u0003\n\u0002\b\u000f\b!\u0018\u0000*\u0006\b\u0000\u0010\u0001 \u00002\u00060\u0002j\u0002`\u0003B\u000f\b\u0000\u0012\u0006\u0010\u0004\u001a\u00020\u0005¢\u0006\u0002\u0010\u0006J\u001f\u0010\u000b\u001a\u00020\f2\b\u0010\r\u001a\u0004\u0018\u00010\u000e2\u0006\u0010\u000f\u001a\u00020\u0010H\u0010¢\u0006\u0002\b\u0011J\u0019\u0010\u0012\u001a\u0004\u0018\u00010\u00102\b\u0010\u0013\u001a\u0004\u0018\u00010\u000eH\u0010¢\u0006\u0002\b\u0014J\u001f\u0010\u0015\u001a\u0002H\u0001\"\u0004\b\u0001\u0010\u00012\b\u0010\u0013\u001a\u0004\u0018\u00010\u000eH\u0010¢\u0006\u0004\b\u0016\u0010\u0017J!\u0010\u0018\u001a\u00020\f2\b\u0010\u0019\u001a\u0004\u0018\u00010\u00102\b\u0010\u001a\u001a\u0004\u0018\u00010\u0010H\u0000¢\u0006\u0002\b\u001bJ\u0006\u0010\u001c\u001a\u00020\fJ\u000f\u0010\u001d\u001a\u0004\u0018\u00010\u000eH ¢\u0006\u0002\b\u001eR\u0018\u0010\u0007\u001a\b\u0012\u0004\u0012\u00028\u00000\bX \u0004¢\u0006\u0006\u001a\u0004\b\t\u0010\nR\u0012\u0010\u0004\u001a\u00020\u00058\u0006@\u0006X\u0087\u000e¢\u0006\u0002\n\u0000¨\u0006\u001f"}, d2 = {"Lkotlinx/coroutines/DispatchedTask;", "T", "Lkotlinx/coroutines/scheduling/Task;", "Lkotlinx/coroutines/SchedulerTask;", "resumeMode", "", "(I)V", "delegate", "Lkotlin/coroutines/Continuation;", "getDelegate$kotlinx_coroutines_core", "()Lkotlin/coroutines/Continuation;", "cancelCompletedResult", "", "takenState", "", "cause", "", "cancelCompletedResult$kotlinx_coroutines_core", "getExceptionalResult", RemoteConfigConstants.ResponseFieldKey.STATE, "getExceptionalResult$kotlinx_coroutines_core", "getSuccessfulResult", "getSuccessfulResult$kotlinx_coroutines_core", "(Ljava/lang/Object;)Ljava/lang/Object;", "handleFatalException", "exception", "finallyException", "handleFatalException$kotlinx_coroutines_core", "run", "takeState", "takeState$kotlinx_coroutines_core", "kotlinx-coroutines-core"}, k = 1, mv = {1, 9, 0}, xi = 48)
@PublishedApi
@SourceDebugExtension({"SMAP\nDispatchedTask.kt\nKotlin\n*S Kotlin\n*F\n+ 1 DispatchedTask.kt\nkotlinx/coroutines/DispatchedTask\n+ 2 fake.kt\nkotlin/jvm/internal/FakeKt\n+ 3 CoroutineContext.kt\nkotlinx/coroutines/CoroutineContextKt\n+ 4 DispatchedTask.kt\nkotlinx/coroutines/DispatchedTaskKt\n+ 5 StackTraceRecovery.kt\nkotlinx/coroutines/internal/StackTraceRecoveryKt\n+ 6 Exceptions.kt\nkotlinx/coroutines/ExceptionsKt\n*L\n1#1,222:1\n1#2:223\n107#3,10:224\n118#3,2:238\n220#4:234\n221#4:237\n61#5,2:235\n74#6:240\n*S KotlinDebug\n*F\n+ 1 DispatchedTask.kt\nkotlinx/coroutines/DispatchedTask\n*L\n90#1:224,10\n90#1:238,2\n103#1:234\n103#1:237\n103#1:235,2\n142#1:240\n*E\n"})
/* loaded from: classes3.dex */
public abstract class DispatchedTask<T> extends Task {
@JvmField
public int resumeMode;
public DispatchedTask(int i) {
this.resumeMode = i;
}
public void cancelCompletedResult$kotlinx_coroutines_core(Object takenState, Throwable cause) {
}
public abstract Continuation<T> getDelegate$kotlinx_coroutines_core();
public Throwable getExceptionalResult$kotlinx_coroutines_core(Object state) {
CompletedExceptionally completedExceptionally = state instanceof CompletedExceptionally ? (CompletedExceptionally) state : null;
if (completedExceptionally != null) {
return completedExceptionally.cause;
}
return null;
}
/* JADX WARN: Multi-variable type inference failed */
public <T> T getSuccessfulResult$kotlinx_coroutines_core(Object state) {
return state;
}
public final void handleFatalException$kotlinx_coroutines_core(Throwable exception, Throwable finallyException) {
if (exception == null && finallyException == null) {
return;
}
if (exception != null && finallyException != null) {
kotlin.ExceptionsKt.addSuppressed(exception, finallyException);
}
if (exception == null) {
exception = finallyException;
}
Intrinsics.checkNotNull(exception);
CoroutineExceptionHandlerKt.handleCoroutineException(getDelegate$kotlinx_coroutines_core().get$context(), new CoroutinesInternalError("Fatal exception in coroutines machinery for " + this + ". Please read KDoc to 'handleFatalException' method and report this incident to maintainers", exception));
}
@Override // java.lang.Runnable
public final void run() {
Object m116constructorimpl;
Object m116constructorimpl2;
TaskContext taskContext = this.taskContext;
try {
Continuation<T> delegate$kotlinx_coroutines_core = getDelegate$kotlinx_coroutines_core();
Intrinsics.checkNotNull(delegate$kotlinx_coroutines_core, "null cannot be cast to non-null type kotlinx.coroutines.internal.DispatchedContinuation<T of kotlinx.coroutines.DispatchedTask>");
DispatchedContinuation dispatchedContinuation = (DispatchedContinuation) delegate$kotlinx_coroutines_core;
Continuation<T> continuation = dispatchedContinuation.continuation;
Object obj = dispatchedContinuation.countOrElement;
CoroutineContext coroutineContext = continuation.get$context();
Object updateThreadContext = ThreadContextKt.updateThreadContext(coroutineContext, obj);
UndispatchedCoroutine<?> updateUndispatchedCompletion = updateThreadContext != ThreadContextKt.NO_THREAD_ELEMENTS ? CoroutineContextKt.updateUndispatchedCompletion(continuation, coroutineContext, updateThreadContext) : null;
try {
CoroutineContext coroutineContext2 = continuation.get$context();
Object takeState$kotlinx_coroutines_core = takeState$kotlinx_coroutines_core();
Throwable exceptionalResult$kotlinx_coroutines_core = getExceptionalResult$kotlinx_coroutines_core(takeState$kotlinx_coroutines_core);
Job job = (exceptionalResult$kotlinx_coroutines_core == null && DispatchedTaskKt.isCancellableMode(this.resumeMode)) ? (Job) coroutineContext2.get(Job.INSTANCE) : null;
if (job != null && !job.isActive()) {
CancellationException cancellationException = job.getCancellationException();
cancelCompletedResult$kotlinx_coroutines_core(takeState$kotlinx_coroutines_core, cancellationException);
Result.Companion companion = Result.INSTANCE;
continuation.resumeWith(Result.m116constructorimpl(ResultKt.createFailure(cancellationException)));
} else if (exceptionalResult$kotlinx_coroutines_core != null) {
Result.Companion companion2 = Result.INSTANCE;
continuation.resumeWith(Result.m116constructorimpl(ResultKt.createFailure(exceptionalResult$kotlinx_coroutines_core)));
} else {
Result.Companion companion3 = Result.INSTANCE;
continuation.resumeWith(Result.m116constructorimpl(getSuccessfulResult$kotlinx_coroutines_core(takeState$kotlinx_coroutines_core)));
}
Unit unit = Unit.INSTANCE;
if (updateUndispatchedCompletion == null || updateUndispatchedCompletion.clearThreadContext()) {
ThreadContextKt.restoreThreadContext(coroutineContext, updateThreadContext);
}
try {
taskContext.afterTask();
m116constructorimpl2 = Result.m116constructorimpl(Unit.INSTANCE);
} catch (Throwable th) {
Result.Companion companion4 = Result.INSTANCE;
m116constructorimpl2 = Result.m116constructorimpl(ResultKt.createFailure(th));
}
handleFatalException$kotlinx_coroutines_core(null, Result.m119exceptionOrNullimpl(m116constructorimpl2));
} catch (Throwable th2) {
if (updateUndispatchedCompletion == null || updateUndispatchedCompletion.clearThreadContext()) {
ThreadContextKt.restoreThreadContext(coroutineContext, updateThreadContext);
}
throw th2;
}
} catch (Throwable th3) {
try {
Result.Companion companion5 = Result.INSTANCE;
taskContext.afterTask();
m116constructorimpl = Result.m116constructorimpl(Unit.INSTANCE);
} catch (Throwable th4) {
Result.Companion companion6 = Result.INSTANCE;
m116constructorimpl = Result.m116constructorimpl(ResultKt.createFailure(th4));
}
handleFatalException$kotlinx_coroutines_core(th3, Result.m119exceptionOrNullimpl(m116constructorimpl));
}
}
public abstract Object takeState$kotlinx_coroutines_core();
}