2016-12-28 21:00:12 +00:00
|
|
|
# ![nio4r](https://raw.github.com/socketry/nio4r/master/logo.png)
|
2016-11-05 04:41:21 +00:00
|
|
|
|
2015-12-23 00:10:22 +00:00
|
|
|
[![Gem Version](https://badge.fury.io/rb/nio4r.svg)](http://rubygems.org/gems/nio4r)
|
2020-09-15 17:38:20 +00:00
|
|
|
[![Build Status](https://github.com/socketry/nio4r/workflows/nio4r/badge.svg?branch=master&event=push)](https://github.com/socketry/nio4r/actions?query=workflow:nio4r)
|
2016-12-28 21:00:12 +00:00
|
|
|
[![Code Climate](https://codeclimate.com/github/socketry/nio4r.svg)](https://codeclimate.com/github/socketry/nio4r)
|
|
|
|
[![Coverage Status](https://coveralls.io/repos/socketry/nio4r/badge.svg?branch=master)](https://coveralls.io/r/socketry/nio4r)
|
2017-12-27 16:33:11 +00:00
|
|
|
[![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/gems/nio4r/2.2.0)
|
2016-11-05 04:56:40 +00:00
|
|
|
|
2016-11-05 04:31:56 +00:00
|
|
|
**New I/O for Ruby (nio4r)**: cross-platform asynchronous I/O primitives for
|
2016-11-05 04:41:21 +00:00
|
|
|
scalable network clients and servers. Modeled after the Java NIO API, but
|
|
|
|
simplified for ease-of-use.
|
2014-01-15 05:40:27 +00:00
|
|
|
|
2016-11-05 04:31:08 +00:00
|
|
|
**nio4r** provides an abstract, cross-platform stateful I/O selector API for Ruby.
|
2014-01-15 05:40:27 +00:00
|
|
|
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.
|
|
|
|
|
2016-11-05 04:41:21 +00:00
|
|
|
## Projects using nio4r
|
|
|
|
|
|
|
|
* [ActionCable]: Rails 5 WebSocket protocol, uses nio4r for a WebSocket server
|
2020-09-07 07:38:59 +00:00
|
|
|
* [Celluloid]: Actor-based concurrency framework, uses nio4r for async I/O
|
|
|
|
* [Async]: Asynchronous I/O framework for Ruby
|
2019-08-05 18:20:38 +00:00
|
|
|
* [Puma]: Ruby/Rack web server built for concurrency
|
2014-01-15 05:40:27 +00:00
|
|
|
|
2016-11-05 04:41:21 +00:00
|
|
|
[ActionCable]: https://rubygems.org/gems/actioncable
|
2020-09-07 07:38:59 +00:00
|
|
|
[Celluloid]: https://github.com/celluloid/celluloid-io
|
|
|
|
[Async]: https://github.com/socketry/async
|
2019-08-05 18:20:38 +00:00
|
|
|
[Puma]: https://github.com/puma/puma
|
2014-01-15 05:40:27 +00:00
|
|
|
|
2016-11-05 04:41:21 +00:00
|
|
|
## Goals
|
2014-01-15 05:40:27 +00:00
|
|
|
|
|
|
|
* 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
|
2011-12-22 06:47:59 +00:00
|
|
|
* Provide inherently thread-safe facilities for working with IO objects
|
|
|
|
|
2016-11-05 04:42:19 +00:00
|
|
|
## Supported platforms
|
2011-12-22 06:47:59 +00:00
|
|
|
|
2016-12-25 18:55:02 +00:00
|
|
|
* Ruby 2.4
|
2018-06-11 12:27:46 +00:00
|
|
|
* Ruby 2.5
|
2019-01-08 22:15:11 +00:00
|
|
|
* Ruby 2.6
|
2020-02-07 08:10:32 +00:00
|
|
|
* Ruby 2.7
|
2020-12-29 19:01:17 +00:00
|
|
|
* Ruby 3.0
|
2019-07-07 09:16:01 +00:00
|
|
|
* [JRuby](https://github.com/jruby/jruby)
|
|
|
|
* [TruffleRuby](https://github.com/oracle/truffleruby)
|
2011-12-22 06:47:59 +00:00
|
|
|
|
2016-12-28 20:56:08 +00:00
|
|
|
## Supported backends
|
2011-12-23 01:15:08 +00:00
|
|
|
|
2016-12-28 20:56:08 +00:00
|
|
|
* **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
|
2011-12-22 06:51:03 +00:00
|
|
|
|
2016-12-28 20:56:08 +00:00
|
|
|
## Documentation
|
2011-12-25 21:06:13 +00:00
|
|
|
|
2016-12-28 21:00:12 +00:00
|
|
|
[Please see the nio4r wiki](https://github.com/socketry/nio4r/wiki)
|
2016-12-28 20:56:08 +00:00
|
|
|
for more detailed documentation and usage notes:
|
2016-11-05 04:46:57 +00:00
|
|
|
|
2016-12-28 20:56:08 +00:00
|
|
|
* [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
|
2016-11-05 04:46:57 +00:00
|
|
|
|
2016-12-28 21:00:12 +00:00
|
|
|
[Getting Started]: https://github.com/socketry/nio4r/wiki/Getting-Started
|
|
|
|
[Selectors]: https://github.com/socketry/nio4r/wiki/Selectors
|
|
|
|
[Monitors]: https://github.com/socketry/nio4r/wiki/Monitors
|
|
|
|
[Byte Buffers]: https://github.com/socketry/nio4r/wiki/Byte-Buffers
|
2016-11-05 04:46:57 +00:00
|
|
|
|
2016-12-28 20:56:08 +00:00
|
|
|
See also:
|
2012-01-08 04:58:24 +00:00
|
|
|
|
2016-12-28 20:56:08 +00:00
|
|
|
* [YARD API documentation](http://www.rubydoc.info/gems/nio4r/frames)
|
2011-12-25 23:54:42 +00:00
|
|
|
|
2016-11-05 04:41:21 +00:00
|
|
|
## Non-goals
|
2011-12-25 21:06:13 +00:00
|
|
|
|
2016-11-05 04:49:31 +00:00
|
|
|
**nio4r** is not a full-featured event framework like [EventMachine] or [Cool.io].
|
2011-12-25 21:06:13 +00:00
|
|
|
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
|
2012-02-11 18:44:28 +00:00
|
|
|
to maintain a large codebase.
|
|
|
|
|
2016-11-05 04:49:31 +00:00
|
|
|
[EventMachine]: https://github.com/eventmachine/eventmachine
|
|
|
|
[Cool.io]: https://coolio.github.io/
|
2011-12-25 21:08:14 +00:00
|
|
|
|
2019-08-28 00:30:57 +00:00
|
|
|
## 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
|
|
|
|
```
|