Request for review / feedback: SocketChannel.poll()
Rob McKenna
rob.mckenna at oracle.com
Wed Oct 2 12:14:51 PDT 2013
Hi folks,
After adding Net.poll() in 7184932, Alan suggested I implement a poll
method in SocketChannel to allow for the temporary use of non-blocking
SocketChannels in a blocking fashion. So this is my first public effort
and is likely quite rough around the edges.
Apologies for the rushed approach, but I'd really like to gather
feedback as soon as possible as we're running quite late for 8. (its
been a busy couple of months unfortunately)
http://cr.openjdk.java.net/~robm/sc.poll/webrev.01/
One thing to note is that in the implementation of poll we have 3 calls
to Net.poll() within 3 conditionals. The reason for this is to allow for
simultaneous calls to sc.poll(OP_READ) and sc.poll(OP_WRITE).
Another part in particular that I'd like to highligh is the awkward
timeout. The spec does say that this method will block if (e.g.) a read
operation is performed in another thread and we poll for OP_READ in our
thread. That is to say, the timeout only comes into play once we have
the appropriate locks. I've also followed the poll system calls
semantics for the timeout parameter. (<0: block indefinitely, 0: return
immediately, >0: block for specified interval)
The test is still a work in progess, but any feedback at all would be
gratefully received.
-Rob
More information about the nio-dev
mailing list