2 ms·
This is the Future impl: trait Future { type Output; fn poll(&mut self, wake: fn()) -> Poll<Self::Output>; } enum Poll<T> {
by pests 3y ago
This is the Future impl:
trait Future {
type Output;
fn poll(&mut self, wake: fn()) -> Poll<Self::Output>;
}
enum Poll<T> {
Ready(T),
Pending,
}
async functions get converted into -> impl Future<Output=original_return_type> automatically.
You poll() until it returns Ready.
wake() will notify you when it's ready to be polled again.
That's it.
Tokio and smol and these runtimes only exist to keep track of these, implement their own API, launch some threads, and run this event loop.