Skip to content

Cross-platform asynchronous I/O primitives for scalable network clients and servers.

License

Notifications You must be signed in to change notification settings

mark-young-atg/nio4r

This branch is 26 commits behind socketry/nio4r:main.

Folders and files

NameName
Last commit message
Last commit date
Jun 1, 2023
Nov 21, 2023
Nov 21, 2023
Nov 21, 2023
Apr 2, 2023
Nov 21, 2023
Mar 30, 2019
Nov 21, 2023
Dec 25, 2016
May 2, 2020
Nov 21, 2023
Jan 9, 2019
Jun 1, 2023
Nov 21, 2023
Jan 15, 2014
Nov 21, 2023
Nov 21, 2023

Repository files navigation

nio4r

Gem Version Build Status Code Climate 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.

# Ensure you have the correct JDK:
pacman -Syu jdk-openjdk
archlinux-java set java-19-openjdk

# Ensure you are using jruby:
chruby jruby
bundle update

# Build the package:
rake clean
rake compile
rake release

About

Cross-platform asynchronous I/O primitives for scalable network clients and servers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 78.9%
  • Ruby 14.1%
  • Java 7.0%