I have experience with the non-blocking IO library epoll
and its high level abstraction libuv
, so when I started learning Rust, I looked for Rust equivalents and found Mio. Mio works the way I understand about non-blocking IO and is familiar to me. I can easily use this kind of API to build high performance server applications using several threads or even a single thread.
Rust 1.39 brought the async
/ await
syntax. I have read some articles and documentation on it and it feels like coroutines. I understand that .await
can be used to yield CPU to do other things in the same thread, but there is no easy way to dynamically schedule code to run in that thread, it doesn't work in an evented way like epoll
, with which I can register events in advance and get notified when those events happen.
The example for async
/ await
of opening and reading files doesn't make sense to me, because in that example after .await
I have nothing to do but wait for the content to be available, so I am still blocking and not async at all.
If I use non-blocking IO like Mio or unsafe epoll
, do I still need async
/ await
? If not, in what cases should I use async
/ await
?