I understand your point. You’re right, with a blocking IO, I had no choice, I had to write on a different thread. But with mio, I didn’t want to add complexity : a channel between threads, a queue to stack all messages to send, register/unregister writable event… I thought to be able to send messages directly from my first thread. But if it is not possible, fine, I will do what is needed.
Not really. For now, my application is using std::net::TcpStream and it is blocking IO. What I want now is to close my application cleanly. I didn’t find a way to stop my threads since they are blocked on a read operation (read on a socket or read on a receiver, but both are blocking). Since I can’t notify threads to stop, I searched a way to have events. I want to be able to set a “cancel event” in my first thread and wait the end of the other thread. So I found mio where I could define my own event with Registration/SetRediness. So I started to try that and working with that.
I guess you have already understook that I’m beginning with Rust Why should I use tokio instead of mio ? What is the difference ? I red that tokio is built on top of mio but since mio seems to have what I need, I didn’t look further. What would be your recommendation ? Thanks for your help !