Open tarcieri opened 9 years ago
@tarcieri I'm having the issue that nonblocking reads with exception: false
are not returning anything meaningful. The documentation states that it will return :wait_readable , but nothing about eof's. Should one assume that if the buffer is empty, it is an EOFError
?
I believe it returns nil
on EOF.
You might take a look at the way I did this in http.rb. I was able to eliminate a lot of the redundancy that exists in the implementation in this PR:
https://github.com/httprb/http/blob/master/lib/http/timeout/global.rb#L84
It worked :+1: adapted/copy-pasted your perform_io method to the stream class. Will try to do something similar for the UDPSocket case. But this one seemed to do the trick. Fancy a review when you have the time? (not a lot changed, I guess).
Ruby 2.1 added APIs to perform asynchronous I/O without using exceptions:
I've seen reports of this affording a 2x speedup in async I/O performance, at least on MRI.
I do not know the status of this API on JRuby et al (cc @headius)