3 ms·
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 p
by color_me_not 3y 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?
- ordu 3y ago> the await keyword will run it asynchronously? 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.
- color_me_not 3y agoThank you. So, it seems I had understood the principle the way you explain it, but the code comment on print_point (as I indicated in the top of this thread) isn't saying that.