|
|
|
|
|
by color_me_not
841 days ago
|
|
So, you mean that this thunk is produced by the async function, and the await keyword will run it asynchronously? In other words, print produces a thunk, and print_point also produces a thunk, and when await is used on the later, it is executed asynchronously, which will execute the print also asynchronously. So we end up with 3 different execution context: the main one, a one for each "await"? What is the point of this, as opposed to executing the thunk asynchronously right away? Also, how does one get the result? |
|
From the point of view of print_point await executes the thunk synchronously, print_point execution stops and awaits for print to finish it work. But a callee of print_point might want it to run print_point asynchronously, so print_point is an async fn, and callee can do something more creative then to await.