Description
Location
https://doc.rust-lang.org/std/future/trait.Future.html
Summary
A future represents an asynchronous computation obtained by use of
async
.
this is not always true, a future represents a value that can be joined into an async function using await
, however futures can be returned by non-async functions, such as tokio::task::spawn
Runtime characteristics
Futures alone are inert; they must be actively polled to make progress, meaning that each time the current task is woken up, it should actively re-poll pending futures that it still has an interest in.
once again, this is true for futures created by calling async functions, but may not be true for all types that implement the Future trait, such as tokio::task::JoinHandle
.
the distinction between futures that are and are not inert is important, an array of task::JoinHandle
is useful for performing several operations concurrently, however an array of futures created by calling async functions will not result in concurrent execution if they are await
ed sequentially.