package kotlinx.coroutines; import kotlin.coroutines.Continuation; import kotlin.coroutines.CoroutineContext; import kotlin.jvm.functions.Function2; /* loaded from: classes5.dex */ public abstract class AbstractCoroutine extends JobSupport implements Job, Continuation, CoroutineScope { public final CoroutineContext context; @Override // kotlin.coroutines.Continuation public final CoroutineContext getContext() { return this.context; } @Override // kotlinx.coroutines.CoroutineScope public CoroutineContext getCoroutineContext() { return this.context; } public void onCancelled(Throwable th, boolean z) { } public void onCompleted(Object obj) { } public AbstractCoroutine(CoroutineContext coroutineContext, boolean z, boolean z2) { super(z2); if (z) { initParentJob((Job) coroutineContext.get(Job.Key)); } this.context = coroutineContext.plus(this); } @Override // kotlinx.coroutines.JobSupport, kotlinx.coroutines.Job public boolean isActive() { return super.isActive(); } @Override // kotlinx.coroutines.JobSupport public String cancellationExceptionMessage() { return DebugStringsKt.getClassSimpleName(this) + " was cancelled"; } @Override // kotlinx.coroutines.JobSupport public final void onCompletionInternal(Object obj) { if (obj instanceof CompletedExceptionally) { CompletedExceptionally completedExceptionally = (CompletedExceptionally) obj; onCancelled(completedExceptionally.cause, completedExceptionally.getHandled()); } else { onCompleted(obj); } } @Override // kotlin.coroutines.Continuation public final void resumeWith(Object obj) { Object makeCompletingOnce$kotlinx_coroutines_core = makeCompletingOnce$kotlinx_coroutines_core(CompletionStateKt.toState$default(obj, null, 1, null)); if (makeCompletingOnce$kotlinx_coroutines_core == JobSupportKt.COMPLETING_WAITING_CHILDREN) { return; } afterResume(makeCompletingOnce$kotlinx_coroutines_core); } public void afterResume(Object obj) { afterCompletion(obj); } @Override // kotlinx.coroutines.JobSupport public final void handleOnCompletionException$kotlinx_coroutines_core(Throwable th) { CoroutineExceptionHandlerKt.handleCoroutineException(this.context, th); } @Override // kotlinx.coroutines.JobSupport public String nameString$kotlinx_coroutines_core() { String coroutineName = CoroutineContextKt.getCoroutineName(this.context); if (coroutineName == null) { return super.nameString$kotlinx_coroutines_core(); } return '\"' + coroutineName + "\":" + super.nameString$kotlinx_coroutines_core(); } public final void start(CoroutineStart coroutineStart, Object obj, Function2 function2) { coroutineStart.invoke(function2, obj, this); } }