by cmckn · 6y ago · 0 comments
I also found this blurb from the website to be confusing:
> Zero-cost abstractions Tokio's run-time model adds no overhead compared to an equivalent system written entirely by hand.
This sounds like Tokio's impl is comparable to other impl's of "the same" system, but how does it compare to "naked Rust"?
One of the surprising things with rust here, is that it define only the syntax and some bare traits AND ALLOW TO PLUG ANY RUNTIME.
This mean you can "swap" runtime implementations and even build your own.
One recent example is:
https://www.reddit.com/r/rust/comments/g917ad/smol_stjepang_...
This is in contrast with Go/Erlang/.NET, etc where the runtime for it is made for you, but can't be changed. This is cool where things are mostly fine all the time, but rust being a SYSTEM lang allow this is neat (example: Embebed scenarios where a regular runtime is too heavy).
Note: This template show in other places, where for example you can swap the allocator or the (default) hash function.
If `Future::poll` returns Pending, once it becomes ready to do more work, it notifies the executor, the executor then schedules the future to be polled again.
The compiler desugar the async/await to state machines and that is melted away by regular means. Also, the quality of the runtime elected must take some credit.