This is a reimplementation of MRI's IO#select logic. It has been rewritten
from an earlier version in JRuby to improve performance and readability.
This version avoids allocating a selector or any data structures to hold
data about the channels/IOs being selected unless absolutely necessary. It
also uses simple boolean arrays to track characteristics like whether an IO
is pending or unselectable, rather than maintaining Set structures. It avoids
hitting Java Integration code to get IO objects out of the incoming Array.
Finally, it tries to build a minimal number of data structures an reuse them
as much as possible.