# \[ANN\] nio4r 2.0.0: cross-platform asynchronous I/O primitives for Ruby

**URL:** <https://rubytalk.org/t/ann-nio4r-2-0-0-cross-platform-asynchronous-i-o-primitives-for-ruby/73974>\
**Category:** ruby-talk\
**Created:** [29 December 2016 03:23 UTC](https://rubytalk.org/t/ann-nio4r-2-0-0-cross-platform-asynchronous-i-o-primitives-for-ruby/73974 "2016-12-29T03:23:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tony\_Arcieri1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/tony_arcieri1/32/1864_2.png) [@Tony\_Arcieri1](https://rubytalk.org/u/Tony_Arcieri1)\
**Post date:** [29 December 2016 03:23 UTC](https://rubytalk.org/t/ann-nio4r-2-0-0-cross-platform-asynchronous-i-o-primitives-for-ruby/73974/1 "2016-12-29T03:23:10Z")

</div>

nio4r is a set of low-level asynchronous I/O primitives with multiple  
cross-platform native code backends including a C extension based on libev,  
a java.nio backend for JRuby, and a pure Ruby version based on  
Kernel.select:

> **[socketry/nio4r](https://github.com/socketry/nio4r)**
>
> nio4r - New I/O for Ruby: Cross-platform asynchronous I/O primitives for scalable network clients and servers

ActionCable, a web socket framework included with Rails 5, uses nio4r for  
monitoring multiple WebSockets for I/O readiness.

> **···**
>
> --
> 
> nio4r 2.0.0 primarily includes new features and bugfixes, with few breaking  
> changes. The primary reason for bumping the major version is dropping  
> support for all Ruby versions prior to 2.2.2.
> 
> The main new feature announcement is NIO::ByteBuffer: a StringIO-like type  
> backed by native code implementations which can be used for  
> high-performance non-blocking I/O. The implementation was contributed to  
> nio4r as a Google Summer of Code project by Upekshe Jayasekera:
> 
> > **[socketry/nio4r](https://github.com/socketry/nio4r/wiki/Byte-Buffers)**
> >
> > nio4r - New I/O for Ruby: Cross-platform asynchronous I/O primitives for scalable network clients and servers
> 
> nio4r is now located under the GitHub "socketry" project. Expect more  
> socketry-related announcements soon!
> 
> Full change log:
> 
> &nbsp;&nbsp;&nbsp;-
> 
> &nbsp;&nbsp;&nbsp;#53 \<[https://github.com/socketry/nio4r/pull/53](https://github.com/socketry/nio4r/pull/53)\> Limit lock scope to  
> &nbsp;&nbsp;&nbsp;prevent recursive locking. (@johnnyt \<[https://github.com/johnnyt](https://github.com/johnnyt)\>)  
> &nbsp;&nbsp;&nbsp;-
> 
> &nbsp;&nbsp;&nbsp;#95 \<[https://github.com/socketry/nio4r/pull/95](https://github.com/socketry/nio4r/pull/95)\> NIO::ByteBuffer Google  
> &nbsp;&nbsp;&nbsp;Summer of Code project. (@UpeksheJay \<[https://github.com/UpeksheJay](https://github.com/UpeksheJay)\>,  
> &nbsp;&nbsp;&nbsp;@tarcieri \<[https://github.com/tarcieri](https://github.com/tarcieri)\>)  
> &nbsp;&nbsp;&nbsp;-
> 
> &nbsp;&nbsp;&nbsp;#111 \<[https://github.com/socketry/nio4r/pull/111](https://github.com/socketry/nio4r/pull/111)\> NIO::Selector#backend  
> &nbsp;&nbsp;&nbsp;introspection support. (@tarcieri \<[https://github.com/tarcieri](https://github.com/tarcieri)\>)  
> &nbsp;&nbsp;&nbsp;-
> 
> &nbsp;&nbsp;&nbsp;#112 \<[https://github.com/socketry/nio4r/pull/112](https://github.com/socketry/nio4r/pull/112)\> Upgrade to libev 4.23.  
> &nbsp;&nbsp;&nbsp;(@tarcieri \<[https://github.com/tarcieri](https://github.com/tarcieri)\>)  
> &nbsp;&nbsp;&nbsp;-
> 
> &nbsp;&nbsp;&nbsp;#119 \<[https://github.com/socketry/nio4r/pull/119](https://github.com/socketry/nio4r/pull/119)\> Disambiguate wakeup vs  
> &nbsp;&nbsp;&nbsp;timeout (fixes #63, #66). (@tarcieri \<[https://github.com/tarcieri](https://github.com/tarcieri)\>)  
> &nbsp;&nbsp;&nbsp;-
> 
> &nbsp;&nbsp;&nbsp;#124 \<[https://github.com/socketry/nio4r/pull/124](https://github.com/socketry/nio4r/pull/124)\> Monitor interests API  
> &nbsp;&nbsp;&nbsp;improvements. (@tarcieri \<[https://github.com/tarcieri](https://github.com/tarcieri)\>)  
> &nbsp;&nbsp;&nbsp;-
> 
> &nbsp;&nbsp;&nbsp;Drop Ruby 2.0 and 2.1 support, require Ruby 2.2.2+. (@tarcieri  
> &nbsp;&nbsp;&nbsp;\<[https://github.com/tarcieri](https://github.com/tarcieri)\>)
> 
> --  
> Tony Arcieri

---

<div class="post-metadata">

**Author:** ![Tony\_Arcieri1](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/tony_arcieri1/32/1864_2.png) [@Tony\_Arcieri1](https://rubytalk.org/u/Tony_Arcieri1)\
**Post date:** [29 December 2016 17:06 UTC](https://rubytalk.org/t/ann-nio4r-2-0-0-cross-platform-asynchronous-i-o-primitives-for-ruby/73974/2 "2016-12-29T17:06:58Z")

</div>

> \* Are bytebuffers to be integrated in celluloid-io?

I've been planning on doing another release of Celluloid soon. I might look  
at doing integration work then.

> They certainly seem to be a candidate, specially the tcp socket buffer  
> operations, but since nio4r moved organization, and celluloid-io being in  
> maintenance mode/not receiving contributions at all for quite some time,  
> this might be unclear.

Right now I've been playing with making an async/await framework for Ruby  
which is much simpler than Celluloid::IO. But yes, Celluloid::IO is a  
candidate for such buffers.

> \* I've checked the signatures for read\_from and write\_to from io's,and one  
> can't set read/write timeouts.

read\_from / write\_to are non-blocking, so timeouts are irrelevant.

> **···**
>
> On Thu, Dec 29, 2016 at 7:01 AM, Tiago Cardoso \<honeyryderchuck@gmail.com\> wrote:
> 
> --  
> Tony Arcieri
