Cross-platform asynchronous I/O primitives for scalable network clients and servers. https://github.com/socketry/nio4r
Go to file
MSP-Greg 74a7ca2a42 Actions - remove Ubuntu-16.04, macOS to 11, add Ubuntu-22.04, Win 2022 2022-10-10 14:12:39 +13:00
.github/workflows Actions - remove Ubuntu-16.04, macOS to 11, add Ubuntu-22.04, Win 2022 2022-10-10 14:12:39 +13:00
examples Fix Style/ExpandPathArguments 2020-01-10 17:43:49 +13:00
ext allow missing `devkit` 2021-09-29 09:08:00 +13:00
lib Bump patch version. 2021-08-03 23:09:20 +12:00
rakelib Java Extension: use at least Java 1.8, avoid warnings 2019-01-09 18:13:12 +13:00
spec Allow pure Ruby and Java NIO::Selector to be initialized with nil 2021-01-05 19:21:15 +13:00
.gitignore .gitignore - add .rspec_status [skip ci] 2019-03-30 17:51:13 +13:00
.rspec Test on Ruby 2.4.0 2016-12-25 11:01:57 -08:00
.rubocop.yml Fix warning: Use `result.unpack1("i")` instead of `result.unpack("i").first`. (convention:Style/UnpackFirst) 2020-05-02 20:11:19 +12:00
CHANGES.md Add missing changelogs for v2.5.6 v2.5.7 v2.5.8 2021-09-02 22:10:43 +12:00
Gemfile Remove guard from Gemfile. 2021-08-03 22:58:38 +12:00
README.md Add license file. Fixes #228, #282. 2022-08-18 16:24:08 +12:00
Rakefile Java Extension: use at least Java 1.8, avoid warnings 2019-01-09 18:13:12 +13:00
license.md Add license file. Fixes #228, #282. 2022-08-18 16:24:08 +12:00
logo.png Smaller logo 2014-01-14 21:44:47 -08:00
nio4r.gemspec Update rubocop version to 2.4 2020-05-02 20:11:19 +12:00

README.md

nio4r

Gem Version Build Status Code Climate Coverage Status Yard Docs

New I/O for Ruby (nio4r): cross-platform asynchronous I/O primitives for scalable network clients and servers. Modeled after the Java NIO API, but simplified for ease-of-use.

nio4r provides an abstract, cross-platform stateful I/O selector API for Ruby. I/O selectors are the heart of "reactor"-based event loops, and monitor multiple I/O objects for various types of readiness, e.g. ready for reading or writing.

Projects using nio4r

  • ActionCable: Rails 5 WebSocket protocol, uses nio4r for a WebSocket server
  • Celluloid: Actor-based concurrency framework, uses nio4r for async I/O
  • Async: Asynchronous I/O framework for Ruby
  • Puma: Ruby/Rack web server built for concurrency

Goals

  • Expose high-level interfaces for stateful IO selectors
  • Keep the API small to maximize both portability and performance across many different OSes and Ruby VMs
  • Provide inherently thread-safe facilities for working with IO objects

Supported platforms

Supported backends

  • libev: MRI C extension targeting multiple native IO selector APIs (e.g epoll, kqueue)
  • Java NIO: JRuby extension which wraps the Java NIO subsystem
  • Pure Ruby: Kernel.select-based backend that should work on any Ruby interpreter

Documentation

Please see the nio4r wiki for more detailed documentation and usage notes:

  • Getting Started: Introduction to nio4r's components
  • Selectors: monitor multiple IO objects for readiness events
  • Monitors: control interests and inspect readiness for specific IO objects
  • Byte Buffers: fixed-size native buffers for high-performance I/O

See also:

Non-goals

nio4r is not a full-featured event framework like EventMachine or Cool.io. Instead, nio4r is the sort of thing you might write a library like that on top of. nio4r provides a minimal API such that individual Ruby implementers may choose to produce optimized versions for their platform, without having to maintain a large codebase.

Releases

CRuby

rake clean
rake release

JRuby

You might need to delete Gemfile.lock before trying to bundle install.

rake clean
rake compile
rake release