Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: