Skip to content
This repository has been archived by the owner on Dec 7, 2018. It is now read-only.

Evaluate exception: false *_nonblock APIs #139

Open
tarcieri opened this issue Apr 15, 2015 · 3 comments
Open

Evaluate exception: false *_nonblock APIs #139

tarcieri opened this issue Apr 15, 2015 · 3 comments
Milestone

Comments

@tarcieri
Copy link
Member

Ruby 2.1 added APIs to perform asynchronous I/O without using exceptions:

io.read_nonblock(n, exception: false)

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)

@digitalextremist digitalextremist modified the milestone: 0.18.0 Aug 9, 2015
HoneyryderChuck pushed a commit to HoneyryderChuck/celluloid-io that referenced this issue Jan 8, 2016
…one doesn't need to handle Wait* Exception (Closes celluloid#139)
@HoneyryderChuck
Copy link

@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 ?

@tarcieri
Copy link
Member Author

tarcieri commented Jan 8, 2016

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

@HoneyryderChuck
Copy link

It worked 👍 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).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants