Hello,
Sorry for making multiple posts on the topic I did not implement futures yet myself hence I have trouble understanding them well.
In an earlier post I asked whether a program can make progress while it is waiting for a future to be executed and I got a "depending on what happens inside trpl::run
, yes" answer.
I just read this excerpt from the book: Applying Concurrency with Async - The Rust Programming Language
Note: Because all of this async code runs in an async block in a
trpl::run
call, everything within it can avoid blocking. However, the code outside it will block on therun
function returning. That’s the whole point of thetrpl::run
function: it lets you choose where to block on some set of async code, and thus where to transition between sync and async code. In most async runtimes,run
is actually namedblock_on
for exactly this reason.
So this simply means: whenever I execute a future with a runtime like trpl
, my code blocks until the future is complete. The code inside the async
block passed to the runtime can make progress while waiting for the future to be available.
Correct?