Skip to content

Instantly share code, notes, and snippets.

View chaxiu's full-sized avatar
🎯
Focusing

BoyCoder chaxiu

🎯
Focusing
View GitHub Profile
@chaxiu
chaxiu / block21.kt
Last active October 18, 2020 13:54
// pseudocode
// marked by label
// ↓ ↓
label: whenStart
when (continuation.label) {
0 -> {
...
}
1 -> {
// Have fun!
@Nullable
public static final Object testCoroutine(@NotNull Continuation $completion) {
Object $continuation;
label37: {
if ($completion instanceof <TestSuspendKt$testCoroutine$1>) {
$continuation = (<TestSuspendKt$testCoroutine$1>)$completion;
if ((((<TestSuspendKt$testCoroutine$1>)$continuation).label & Integer.MIN_VALUE) != 0) {
((<TestSuspendKt$testCoroutine$1>)$continuation).label -= Integer.MIN_VALUE;
break label37;

Diagram Coroutines: suspend

1. Preface

Coroutines is the most amazing feature in Kotlin.

In this post, I'll briefly introduce Kotlin coroutines, and then explain Coroutines in the form of Diagram + Animation. After reading this post, you may find out that Coroutines is not that difficult.

Coroutines-dispatch