Description
A frequently requested feature of I/O I've been seeing is some form of nonblocking I/O. This is a vast and broad topic, but I would like to make this concrete proposal:
fn set_nonblocking(&mut self, nonblocking: bool) -> IoResult<()>;
The IoErrorKind
enum would also be extended with a value of WouldBlock
. This method would be added to only the network streams initially and possibly others as later seen fit.
For libnative, this would do the ioctl
thing or whatever the equivalent is to set the file descriptor into nonblocking mode (can this be done on windows?). For librustuv, this could be a little more difficult. To the best of my knowledge libuv doesn't support a nonblocking read. One possible solution would be to schedule a read and then use an idle callback to cancel the read on the next turn of the event loop. This would technically block the task, but it would be for "a short period of time"
Those who desire a form of nonblocking I/O, would this satisfy your needs?