Ever needed to watch multiple IO objects for readiness events? The
technical term is “synchronous I/O multiplexing”. The nio4r gem provides
a
high-performance, cross-platform API for doing just this that works on
MRI/YARV 1.8/1.9, REE, JRuby, and Rubinius:
http://rubydoc.info/gems/nio4r/0.3.1/file/README.md
nio4r is exactly what you need to build the guts of your own
event-driven
I/O system. Ever wanted to build your own EventMachine, Node.js, or
Cool.io? nio4r provides a compact and elegant API for leveraging
high-performance system calls like epoll and kqueue which register IO
objects of interest then notify you when events occur.
On CRubies (including Rubinius) nio4r uses the libev C library (also
used
by Cool.io and node.js) and on JRuby nio4r uses the Java NIO subystem.
This release focuses on improving the robustness, performance, and
semantic
consistency of the JRuby backend. The entire JRuby backend has been
rewritten from scratch as a Java extension for JRuby which should help
improve the performance over the previous implementation, which was
written
in Ruby using the slower Java Interop API.
The spec suite has also been expanded to help smooth out semantic
differences between Ruby platforms.
–
Changes from 0.2.0:
- NIO::Selector#select now takes a block and behaves like select_each
- NIO::Selector#select_each is now deprecated and will be removed
- Closing monitors detaches them from their selector
- Java extension for JRuby
- Upgrade to libev 4.11
- Bugfixes for zero/negative select timeouts
- Handle OP_CONNECT properly on JRuby
- Prevent CancelledKeyExceptions on JRuby