Hacker News new | past | comments | ask | show | jobs | submit login

> There are deeper reasons that readiness was chosen over completion as a model, but I won't get into that right now.

If you've got some time, would you go into those reasons a little bit? Thanks!




Part of why I didn't go into it is because the post was already long, another part is because frankly, it's not my area of expertise and I didn't want to misrepresent it. Please remember that I'm not directly involved in tokio's development, and so this is always my understanding, I might be wrong in places, and you should ask someone on the team to be 100% sure. (The post above is stuff I'm sure about.)

What I will say for sure is that it wasn't "hey we use Unix so we're doing what we know and we'll tack on Windows support", it was made purely on technical merits of the two models. I also know that it was related to allocations.

At a high level, my understanding is that the situation is this: the unices have a rediness model, windows has a completion model. If you want a cross-platform abstraction, you can't get around needing to map one to the other. So the question becomes "is it cheaper to simulate readiness with completion, or completion with readiness."

I _believe_ that the situation is something like this: the completion model requires that you allocate a buffer up front, whereas the readiness model doesn't. So to map readiness to completion, you'd end up allocating the buffer, then doing your calls, then filling the buffer. But to map completion to readiness, you can do a trick: make a call for a zero-byte read, and when that comes back, allocate the buffer, and make another call. There's still a small amount of overhead here, but it's less than the other direction.

Again, I might be wrong here.

oh also, shout out to wio, which is mio, but focusing on just windows: https://github.com/retep998/wio-rs I haven't kept up with it as much as this stuff, but I like the idea.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: