Ajaydeepak07
11/28/2020, 1:20 PMTwoClocks
11/28/2020, 10:27 PMsuspend
function. It figures out what state you need (local vars, etc) and makes sure they are available to all the methods.TwoClocks
11/28/2020, 10:28 PMsuspend
-ing functions, it actually uses a big java switch statment w/ each case: being another section of your function.TwoClocks
11/28/2020, 10:37 PMAjaydeepak07
11/30/2020, 3:26 AMTwoClocks
11/30/2020, 8:29 AMTwoClocks
11/30/2020, 8:37 AMTwoClocks
11/30/2020, 8:47 AMAjaydeepak07
11/30/2020, 5:12 PMuli
12/01/2020, 8:46 PMAjaydeepak07
12/04/2020, 7:18 AMAjaydeepak07
12/04/2020, 7:18 AMuli
12/04/2020, 8:42 AMuli
12/04/2020, 8:43 AMprintln("Start")
delay(1000)
// do the rest
println("Done")
return
uli
12/04/2020, 8:46 AMHandler mainHandler = new Handler(Looper.getMainLooper());
println("Start")
mainHandler.postDelayed {
// do the rest
println("Done")
}
return
uli
12/04/2020, 8:47 AMdelay()
)uli
12/04/2020, 8:49 AMuli
12/04/2020, 8:55 AMuli
12/04/2020, 9:29 AMpublic final Object test(@NotNull Continuation<? super Unit> $completion) {
// Note: $continuation.label tells us where to continue. Initially it will be 0
switch ($continuation.label) {
case 0: {
System.out.println("Start");
// Prepare for suspending
// Save state
$continuation.L$0 = this;
// Remember wheree to continue
$continuation.label = 1;
// Call delay. Just like our own test function this will return before being done
// When delay is really done, we will be called again with L$0 and label as we
// Set it aboove
v0 = DelayKt.delay((long)1000L, (Continuation)$continuation);
// v0 can contain a marker that it is not done yet (COROUTINE_SUSPENDED) or a real
// return value
var6_4 = IntrinsicsKt.getCOROUTINE_SUSPENDED();
if (v0 == var6_4) {
// If delay suspended, we suspend as well, waiting for it's answer
return var6_4;
}
// Otherwise continue imediately with the result of delay
** GOTO lbl25
}
case 1: {
// restore state
this = (ScopedViewModel)$continuation.L$0;
// Get result of delay call
v0 = $continuation.result;
lbl25:
// Do the rest
System.out.println("Done");
// Return real result, not COROUTINE_SUSPENDED, indicating that we completed our jobdo not want to
// and need not be called again
return Unit.INSTANCE;
}
}
}
uli
12/04/2020, 9:37 AMpostDelayed {
test($continuation)
}
to let us continue at label 1