Last active
September 15, 2022 20:44
-
-
Save aleksandarzekovic/87696b101c99229ea2d8bd925a733ba6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal abstract class DispatchedTask<in T>( | |
@JvmField public var resumeMode: Int | |
) : SchedulerTask() { | |
public final override fun run() { | |
// ... | |
try { | |
val delegate = delegate as DispatchedContinuation<T> | |
val continuation = delegate.continuation | |
withContinuationContext(continuation, delegate.countOrElement) { | |
// ... | |
val job = if (exception == null && resumeMode.isCancellableMode) context[Job] else null | |
if (job != null && !job.isActive) { | |
val cause = job.getCancellationException() | |
cancelCompletedResult(state, cause) | |
continuation.resumeWithStackTrace(cause) | |
} else { | |
if (exception != null) { | |
continuation.resumeWithException(exception) | |
} else { | |
continuation.resume(getSuccessfulResult(state)) | |
} | |
} | |
} | |
} | |
// ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment