nio4r 2.5.4 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/workflow.yml +34 -16
  3. data/.mailmap +16 -0
  4. data/Gemfile +5 -5
  5. data/{CHANGES.md → changes.md} +54 -0
  6. data/examples/echo_server.rb +7 -0
  7. data/ext/libev/Changes +71 -2
  8. data/ext/libev/ev.c +611 -198
  9. data/ext/libev/ev.h +25 -22
  10. data/ext/libev/ev_epoll.c +16 -14
  11. data/ext/libev/ev_iouring.c +694 -0
  12. data/ext/libev/ev_kqueue.c +4 -4
  13. data/ext/libev/ev_linuxaio.c +78 -100
  14. data/ext/libev/ev_poll.c +6 -6
  15. data/ext/libev/ev_port.c +3 -3
  16. data/ext/libev/ev_select.c +6 -6
  17. data/ext/libev/ev_vars.h +34 -0
  18. data/ext/libev/ev_win32.c +2 -2
  19. data/ext/libev/ev_wrap.h +56 -0
  20. data/ext/nio4r/bytebuffer.c +75 -38
  21. data/ext/nio4r/extconf.rb +24 -1
  22. data/ext/nio4r/monitor.c +47 -22
  23. data/ext/nio4r/nio4r.h +1 -5
  24. data/ext/nio4r/org/nio4r/ByteBuffer.java +2 -0
  25. data/ext/nio4r/org/nio4r/Monitor.java +1 -0
  26. data/ext/nio4r/org/nio4r/Selector.java +8 -10
  27. data/ext/nio4r/selector.c +88 -48
  28. data/lib/nio/bytebuffer.rb +6 -0
  29. data/lib/nio/monitor.rb +7 -0
  30. data/lib/nio/selector.rb +26 -9
  31. data/lib/nio/version.rb +6 -1
  32. data/lib/nio.rb +29 -1
  33. data/lib/nio4r.rb +5 -0
  34. data/license.md +77 -0
  35. data/nio4r.gemspec +4 -3
  36. data/rakelib/extension.rake +1 -2
  37. data/readme.md +91 -0
  38. data/spec/nio/acceptables_spec.rb +4 -0
  39. data/spec/nio/bytebuffer_spec.rb +6 -0
  40. data/spec/nio/monitor_spec.rb +7 -0
  41. data/spec/nio/selectables/pipe_spec.rb +6 -0
  42. data/spec/nio/selectables/ssl_socket_spec.rb +8 -3
  43. data/spec/nio/selectables/tcp_socket_spec.rb +7 -0
  44. data/spec/nio/selectables/udp_socket_spec.rb +7 -0
  45. data/spec/nio/selector_spec.rb +16 -0
  46. data/spec/spec_helper.rb +7 -2
  47. data/spec/support/selectable_examples.rb +8 -0
  48. metadata +14 -9
  49. data/README.md +0 -132
data/readme.md ADDED
@@ -0,0 +1,91 @@
1
+ # ![nio4r](https://raw.github.com/socketry/nio4r/master/logo.png)
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/nio4r.svg)](http://rubygems.org/gems/nio4r)
4
+ [![Build Status](https://github.com/socketry/nio4r/workflows/nio4r/badge.svg?branch=master&event=push)](https://github.com/socketry/nio4r/actions?query=workflow:nio4r)
5
+ [![Code Climate](https://codeclimate.com/github/socketry/nio4r.svg)](https://codeclimate.com/github/socketry/nio4r)
6
+ [![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/gems/nio4r/2.2.0)
7
+
8
+ **New I/O for Ruby (nio4r)**: cross-platform asynchronous I/O primitives for
9
+ scalable network clients and servers. Modeled after the Java NIO API, but
10
+ simplified for ease-of-use.
11
+
12
+ **nio4r** provides an abstract, cross-platform stateful I/O selector API for Ruby.
13
+ I/O selectors are the heart of "reactor"-based event loops, and monitor
14
+ multiple I/O objects for various types of readiness, e.g. ready for reading or
15
+ writing.
16
+
17
+ ## Projects using nio4r
18
+
19
+ - [ActionCable](https://rubygems.org/gems/actioncable): Rails 5 WebSocket protocol, uses nio4r for a WebSocket server
20
+ - [Celluloid](https://github.com/celluloid/celluloid-io): Actor-based concurrency framework, uses nio4r for async I/O
21
+ - [Async](https://github.com/socketry/async): Asynchronous I/O framework for Ruby
22
+ - [Puma](https://github.com/puma/puma): Ruby/Rack web server built for concurrency
23
+
24
+ ## Goals
25
+
26
+ - Expose high-level interfaces for stateful IO selectors
27
+ - Keep the API small to maximize both portability and performance across many
28
+ different OSes and Ruby VMs
29
+ - Provide inherently thread-safe facilities for working with IO objects
30
+
31
+ ## Supported platforms
32
+
33
+ - Ruby 2.4
34
+ - Ruby 2.5
35
+ - Ruby 2.6
36
+ - Ruby 2.7
37
+ - Ruby 3.0
38
+ - [JRuby](https://github.com/jruby/jruby)
39
+ - [TruffleRuby](https://github.com/oracle/truffleruby)
40
+
41
+ ## Supported backends
42
+
43
+ - **libev**: MRI C extension targeting multiple native IO selector APIs (e.g epoll, kqueue)
44
+ - **Java NIO**: JRuby extension which wraps the Java NIO subsystem
45
+ - **Pure Ruby**: `Kernel.select`-based backend that should work on any Ruby interpreter
46
+
47
+ ## Documentation
48
+
49
+ [Please see the nio4r wiki](https://github.com/socketry/nio4r/wiki)
50
+ for more detailed documentation and usage notes:
51
+
52
+ - [Getting Started](https://github.com/socketry/nio4r/wiki/Getting-Started): Introduction to nio4r's components
53
+ - [Selectors](https://github.com/socketry/nio4r/wiki/Selectors): monitor multiple `IO` objects for readiness events
54
+ - [Monitors](https://github.com/socketry/nio4r/wiki/Monitors): control interests and inspect readiness for specific `IO` objects
55
+ - [Byte Buffers](https://github.com/socketry/nio4r/wiki/Byte-Buffers): fixed-size native buffers for high-performance I/O
56
+
57
+ See also:
58
+
59
+ - [YARD API documentation](http://www.rubydoc.info/gems/nio4r/frames)
60
+
61
+ ## Non-goals
62
+
63
+ **nio4r** is not a full-featured event framework like [EventMachine](https://github.com/eventmachine/eventmachine) or [Cool.io](https://coolio.github.io/).
64
+ Instead, nio4r is the sort of thing you might write a library like that on
65
+ top of. nio4r provides a minimal API such that individual Ruby implementers
66
+ may choose to produce optimized versions for their platform, without having
67
+ to maintain a large codebase.
68
+
69
+ ## Releases
70
+
71
+ ### CRuby
72
+
73
+ rake clean
74
+ rake release
75
+
76
+ ### JRuby
77
+
78
+ You might need to delete `Gemfile.lock` before trying to `bundle install`.
79
+
80
+ # Ensure you have the correct JDK:
81
+ pacman -Syu jdk-openjdk
82
+ archlinux-java set java-19-openjdk
83
+
84
+ # Ensure you are using jruby:
85
+ chruby jruby
86
+ bundle update
87
+
88
+ # Build the package:
89
+ rake clean
90
+ rake compile
91
+ rake release
@@ -1,5 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Released under the MIT License.
4
+ # Copyright, 2012-2017, by Tony Arcieri.
5
+ # Copyright, 2019-2023, by Samuel Williams.
6
+
3
7
  require "spec_helper"
4
8
 
5
9
  RSpec.describe "NIO acceptables" do
@@ -1,5 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Released under the MIT License.
4
+ # Copyright, 2016, by Upekshe Jayasekera.
5
+ # Copyright, 2016-2017, by Tony Arcieri.
6
+ # Copyright, 2019-2023, by Samuel Williams.
7
+ # Copyright, 2020, by Thomas Dziedzic.
8
+
3
9
  require "spec_helper"
4
10
 
5
11
  RSpec.describe NIO::ByteBuffer do
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Released under the MIT License.
4
+ # Copyright, 2011-2018, by Tony Arcieri.
5
+ # Copyright, 2012, by Logan Bowers.
6
+ # Copyright, 2015, by Tiago Cardoso.
7
+ # Copyright, 2015, by Upekshe Jayasekera.
8
+ # Copyright, 2018-2023, by Samuel Williams.
9
+
3
10
  require "spec_helper"
4
11
  require "socket"
5
12
 
@@ -1,5 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Released under the MIT License.
4
+ # Copyright, 2012-2017, by Tony Arcieri.
5
+ # Copyright, 2012, by Logan Bowers.
6
+ # Copyright, 2017, by Gregory Longtin.
7
+ # Copyright, 2023, by Samuel Williams.
8
+
3
9
  require "spec_helper"
4
10
 
5
11
  RSpec.describe "IO.pipe" do
@@ -1,11 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Released under the MIT License.
4
+ # Copyright, 2012-2017, by Tony Arcieri.
5
+ # Copyright, 2012, by Logan Bowers.
6
+ # Copyright, 2017-2020, by Gregory Longtin.
7
+ # Copyright, 2019, by Cédric Boutillier.
8
+ # Copyright, 2019-2023, by Samuel Williams.
9
+
3
10
  require "spec_helper"
11
+ require "openssl"
4
12
 
5
13
  RSpec.describe OpenSSL::SSL::SSLSocket do
6
-
7
- require "openssl"
8
-
9
14
  before(:all) do
10
15
  @tls = []
11
16
  end
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Released under the MIT License.
4
+ # Copyright, 2012-2017, by Tony Arcieri.
5
+ # Copyright, 2012, by Bernd Ahlers.
6
+ # Copyright, 2012, by Logan Bowers.
7
+ # Copyright, 2013, by Tim Carey-Smith.
8
+ # Copyright, 2019-2023, by Samuel Williams.
9
+
3
10
  require "spec_helper"
4
11
 
5
12
  RSpec.describe TCPSocket do
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Released under the MIT License.
4
+ # Copyright, 2012-2017, by Tony Arcieri.
5
+ # Copyright, 2017, by Gregory Longtin.
6
+ # Copyright, 2017, by Olle Jonsson.
7
+ # Copyright, 2019-2023, by Samuel Williams.
8
+ # Copyright, 2020, by Thomas Dziedzic.
9
+
3
10
  require "spec_helper"
4
11
 
5
12
  RSpec.describe UDPSocket, if: !defined?(JRUBY_VERSION) do
@@ -1,5 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Released under the MIT License.
4
+ # Copyright, 2011-2017, by Tony Arcieri.
5
+ # Copyright, 2012, by Logan Bowers.
6
+ # Copyright, 2013, by Ravil Bayramgalin.
7
+ # Copyright, 2013, by Tim Carey-Smith.
8
+ # Copyright, 2015, by Vladimir Kochnev.
9
+ # Copyright, 2016, by Tiago Cardoso.
10
+ # Copyright, 2019-2023, by Samuel Williams.
11
+ # Copyright, 2019, by Jesús Burgos Maciá.
12
+ # Copyright, 2020, by Thomas Dziedzic.
13
+ # Copyright, 2021, by Joao Fernandes.
14
+
3
15
  require "spec_helper"
4
16
  require "timeout"
5
17
 
@@ -24,6 +36,10 @@ RSpec.describe NIO::Selector do
24
36
  example.reporter.message "Supported backends: #{described_class.backends}"
25
37
  end
26
38
 
39
+ it "automatically selects a backend if none or nil is specified" do
40
+ expect(described_class.new.backend).to eq described_class.new(nil).backend
41
+ end
42
+
27
43
  it "raises ArgumentError if given an invalid backend" do
28
44
  expect { described_class.new(:derp) }.to raise_error ArgumentError
29
45
  end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "coveralls"
4
- Coveralls.wear!
3
+ # Released under the MIT License.
4
+ # Copyright, 2011-2017, by Tony Arcieri.
5
+ # Copyright, 2017, by Gregory Longtin.
6
+ # Copyright, 2019-2023, by Samuel Williams.
7
+ # Copyright, 2021, by Joao Fernandes.
5
8
 
6
9
  require "nio"
7
10
  require "support/selectable_examples"
@@ -12,6 +15,8 @@ RSpec.configure do |config|
12
15
  # Enable flags like --only-failures and --next-failure
13
16
  config.example_status_persistence_file_path = ".rspec_status"
14
17
 
18
+ config.filter_run_when_matching :focus
19
+
15
20
  config.expect_with :rspec do |c|
16
21
  c.syntax = :expect
17
22
  end
@@ -1,5 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Released under the MIT License.
4
+ # Copyright, 2012-2017, by Tony Arcieri.
5
+ # Copyright, 2012, by Logan Bowers.
6
+ # Copyright, 2013, by Tim Carey-Smith.
7
+ # Copyright, 2017-2019, by Gregory Longtin.
8
+ # Copyright, 2017, by Tiago Cardoso.
9
+ # Copyright, 2019-2023, by Samuel Williams.
10
+
3
11
  RSpec.shared_context NIO::Selector do
4
12
  let(:selector) {@selector = NIO::Selector.new}
5
13
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nio4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.4
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Arcieri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-15 00:00:00.000000000 Z
11
+ date: 2023-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -49,12 +49,12 @@ extra_rdoc_files: []
49
49
  files:
50
50
  - ".github/workflows/workflow.yml"
51
51
  - ".gitignore"
52
+ - ".mailmap"
52
53
  - ".rspec"
53
54
  - ".rubocop.yml"
54
- - CHANGES.md
55
55
  - Gemfile
56
- - README.md
57
56
  - Rakefile
57
+ - changes.md
58
58
  - examples/echo_server.rb
59
59
  - ext/libev/Changes
60
60
  - ext/libev/LICENSE
@@ -62,6 +62,7 @@ files:
62
62
  - ext/libev/ev.c
63
63
  - ext/libev/ev.h
64
64
  - ext/libev/ev_epoll.c
65
+ - ext/libev/ev_iouring.c
65
66
  - ext/libev/ev_kqueue.c
66
67
  - ext/libev/ev_linuxaio.c
67
68
  - ext/libev/ev_poll.c
@@ -87,11 +88,14 @@ files:
87
88
  - lib/nio/monitor.rb
88
89
  - lib/nio/selector.rb
89
90
  - lib/nio/version.rb
91
+ - lib/nio4r.rb
92
+ - license.md
90
93
  - logo.png
91
94
  - nio4r.gemspec
92
95
  - rakelib/extension.rake
93
96
  - rakelib/rspec.rake
94
97
  - rakelib/rubocop.rake
98
+ - readme.md
95
99
  - spec/nio/acceptables_spec.rb
96
100
  - spec/nio/bytebuffer_spec.rb
97
101
  - spec/nio/monitor_spec.rb
@@ -104,13 +108,14 @@ files:
104
108
  - spec/support/selectable_examples.rb
105
109
  homepage: https://github.com/socketry/nio4r
106
110
  licenses:
107
- - MIT
111
+ - MIT AND (BSD-2-Clause OR GPL-2.0-or-later)
108
112
  metadata:
109
113
  bug_tracker_uri: https://github.com/socketry/nio4r/issues
110
- changelog_uri: https://github.com/socketry/nio4r/blob/master/CHANGES.md
111
- documentation_uri: https://www.rubydoc.info/gems/nio4r/2.5.4
112
- source_code_uri: https://github.com/socketry/nio4r/tree/v2.5.4
114
+ changelog_uri: https://github.com/socketry/nio4r/blob/main/changes.md
115
+ documentation_uri: https://www.rubydoc.info/gems/nio4r/2.6.1
116
+ source_code_uri: https://github.com/socketry/nio4r/tree/v2.6.1
113
117
  wiki_uri: https://github.com/socketry/nio4r/wiki
118
+ funding_uri: https://github.com/sponsors/ioquatix/
114
119
  post_install_message:
115
120
  rdoc_options: []
116
121
  require_paths:
@@ -126,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
131
  - !ruby/object:Gem::Version
127
132
  version: '0'
128
133
  requirements: []
129
- rubygems_version: 3.1.2
134
+ rubygems_version: 3.4.22
130
135
  signing_key:
131
136
  specification_version: 4
132
137
  summary: New IO for Ruby
data/README.md DELETED
@@ -1,132 +0,0 @@
1
- # ![nio4r](https://raw.github.com/socketry/nio4r/master/logo.png)
2
-
3
- [![Gem Version](https://badge.fury.io/rb/nio4r.svg)](http://rubygems.org/gems/nio4r)
4
- [![Build Status](https://github.com/socketry/nio4r/workflows/nio4r/badge.svg?branch=master&event=push)](https://github.com/socketry/nio4r/actions?query=workflow:nio4r)
5
- [![Code Climate](https://codeclimate.com/github/socketry/nio4r.svg)](https://codeclimate.com/github/socketry/nio4r)
6
- [![Coverage Status](https://coveralls.io/repos/socketry/nio4r/badge.svg?branch=master)](https://coveralls.io/r/socketry/nio4r)
7
- [![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](http://www.rubydoc.info/gems/nio4r/2.2.0)
8
-
9
- **New I/O for Ruby (nio4r)**: cross-platform asynchronous I/O primitives for
10
- scalable network clients and servers. Modeled after the Java NIO API, but
11
- simplified for ease-of-use.
12
-
13
- **nio4r** provides an abstract, cross-platform stateful I/O selector API for Ruby.
14
- I/O selectors are the heart of "reactor"-based event loops, and monitor
15
- multiple I/O objects for various types of readiness, e.g. ready for reading or
16
- writing.
17
-
18
- ## Projects using nio4r
19
-
20
- * [ActionCable]: Rails 5 WebSocket protocol, uses nio4r for a WebSocket server
21
- * [Celluloid]: Actor-based concurrency framework, uses nio4r for async I/O
22
- * [Async]: Asynchronous I/O framework for Ruby
23
- * [Puma]: Ruby/Rack web server built for concurrency
24
-
25
- [ActionCable]: https://rubygems.org/gems/actioncable
26
- [Celluloid]: https://github.com/celluloid/celluloid-io
27
- [Async]: https://github.com/socketry/async
28
- [Puma]: https://github.com/puma/puma
29
-
30
- ## Goals
31
-
32
- * Expose high-level interfaces for stateful IO selectors
33
- * Keep the API small to maximize both portability and performance across many
34
- different OSes and Ruby VMs
35
- * Provide inherently thread-safe facilities for working with IO objects
36
-
37
- ## Supported platforms
38
-
39
- * Ruby 2.4
40
- * Ruby 2.5
41
- * Ruby 2.6
42
- * Ruby 2.7
43
- * [JRuby](https://github.com/jruby/jruby)
44
- * [TruffleRuby](https://github.com/oracle/truffleruby)
45
-
46
- ## Supported backends
47
-
48
- * **libev**: MRI C extension targeting multiple native IO selector APIs (e.g epoll, kqueue)
49
- * **Java NIO**: JRuby extension which wraps the Java NIO subsystem
50
- * **Pure Ruby**: `Kernel.select`-based backend that should work on any Ruby interpreter
51
-
52
- ## Documentation
53
-
54
- [Please see the nio4r wiki](https://github.com/socketry/nio4r/wiki)
55
- for more detailed documentation and usage notes:
56
-
57
- * [Getting Started]: Introduction to nio4r's components
58
- * [Selectors]: monitor multiple `IO` objects for readiness events
59
- * [Monitors]: control interests and inspect readiness for specific `IO` objects
60
- * [Byte Buffers]: fixed-size native buffers for high-performance I/O
61
-
62
- [Getting Started]: https://github.com/socketry/nio4r/wiki/Getting-Started
63
- [Selectors]: https://github.com/socketry/nio4r/wiki/Selectors
64
- [Monitors]: https://github.com/socketry/nio4r/wiki/Monitors
65
- [Byte Buffers]: https://github.com/socketry/nio4r/wiki/Byte-Buffers
66
-
67
- See also:
68
-
69
- * [YARD API documentation](http://www.rubydoc.info/gems/nio4r/frames)
70
-
71
- ## Non-goals
72
-
73
- **nio4r** is not a full-featured event framework like [EventMachine] or [Cool.io].
74
- Instead, nio4r is the sort of thing you might write a library like that on
75
- top of. nio4r provides a minimal API such that individual Ruby implementers
76
- may choose to produce optimized versions for their platform, without having
77
- to maintain a large codebase.
78
-
79
- [EventMachine]: https://github.com/eventmachine/eventmachine
80
- [Cool.io]: https://coolio.github.io/
81
-
82
- ## Releases
83
-
84
- ### CRuby
85
-
86
- ```
87
- rake clean
88
- rake release
89
- ```
90
-
91
- ### JRuby
92
-
93
- You might need to delete `Gemfile.lock` before trying to `bundle install`.
94
-
95
- ```
96
- rake clean
97
- rake compile
98
- rake release
99
- ```
100
-
101
- ## License
102
-
103
- Released under the MIT license.
104
-
105
- Copyright, 2019, by Tony Arcieri.
106
- Copyright, 2019, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
107
-
108
- Permission is hereby granted, free of charge, to any person obtaining a copy
109
- of this software and associated documentation files (the "Software"), to deal
110
- in the Software without restriction, including without limitation the rights
111
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
112
- copies of the Software, and to permit persons to whom the Software is
113
- furnished to do so, subject to the following conditions:
114
-
115
- The above copyright notice and this permission notice shall be included in
116
- all copies or substantial portions of the Software.
117
-
118
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
119
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
120
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
121
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
122
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
123
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
124
- THE SOFTWARE.
125
-
126
- ### libev
127
-
128
- Released under the BSD license. See [ext/libev/LICENSE] for details.
129
-
130
- Copyright, 2007-2019, by Marc Alexander Lehmann.
131
-
132
- [ext/libev/LICENSE]: https://github.com/socketry/nio4r/blob/master/ext/libev/LICENSE