add one step in async

This commit is contained in:
shenjack 2024-03-17 18:59:57 +08:00
parent 839400a238
commit df26a93893
Signed by: shenjack
GPG Key ID: 7B1134A979775551
2 changed files with 33 additions and 0 deletions

View File

@ -3639,6 +3639,28 @@
return H.setRuntimeTypeInfo([], t1);
return H.setRuntimeTypeInfo(["a", "b", "c"], t1);
},
b_run: function () {
var $async$goto = 0,
$async$completer = P._makeAsyncAwaitCompleter(type$.dynamic);
var $async$b_run = P._wrapJsFunctionForAsync(function ($async$errorCode, $async$result) {
if ($async$errorCode === 1)
return P._asyncRethrow($async$result, $async$completer);
while (true)
switch ($async$goto) {
case 0:
// Function start
P.print("object in b_run");
$async$goto = 2;
return P._asyncAwait(V.md5run(), $async$b_run);
case 2:
// returning from await.
P.print("object after 1s");
// implicit return
return P._asyncReturn(null, $async$completer);
}
});
return P._asyncStartSync($async$b_run, $async$completer);
},
md5run: function () {
var $async$goto = 0,
$async$completer = P._makeAsyncAwaitCompleter(type$.dynamic);
@ -3675,6 +3697,10 @@
$async$goto = 2;
return P._asyncAwait(V.md5run(), $async$a_run);
case 2:
// returning from await.
$async$goto = 3;
return P._asyncAwait(V.b_run(), $async$a_run);
case 3:
// returning from await.
P.print("object after 1s");
// implicit return

View File

@ -63,6 +63,12 @@ List<String> test_list(String str) {
}
b_run() async {
print("object in b_run");
await md5run();
print("object after 1s");
}
md5run() async{
print("object in md5run");
await Future.delayed(Duration(milliseconds: 1000));
@ -72,6 +78,7 @@ md5run() async{
a_run() async{
print("object");
await md5run();
await b_run();
print("object after 1s");
}