nio4r 2.0.0.pre-java → 2.1.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +0 -1
- data/.rubocop.yml +31 -38
- data/.ruby-version +1 -0
- data/.travis.yml +9 -19
- data/CHANGES.md +94 -42
- data/Gemfile +11 -3
- data/Guardfile +10 -0
- data/LICENSE.txt +1 -1
- data/README.md +43 -136
- data/Rakefile +2 -0
- data/examples/echo_server.rb +1 -0
- data/ext/libev/Changes +9 -13
- data/ext/libev/ev.c +100 -74
- data/ext/libev/ev.h +4 -9
- data/ext/libev/ev_epoll.c +6 -3
- data/ext/libev/ev_kqueue.c +8 -4
- data/ext/libev/ev_poll.c +6 -3
- data/ext/libev/ev_port.c +8 -4
- data/ext/libev/ev_select.c +4 -2
- data/ext/nio4r/bytebuffer.c +265 -257
- data/ext/nio4r/extconf.rb +3 -9
- data/ext/nio4r/monitor.c +93 -46
- data/ext/nio4r/nio4r.h +6 -16
- data/ext/nio4r/org/nio4r/ByteBuffer.java +193 -209
- data/ext/nio4r/org/nio4r/Monitor.java +164 -0
- data/ext/nio4r/org/nio4r/Nio4r.java +13 -391
- data/ext/nio4r/org/nio4r/Selector.java +278 -0
- data/ext/nio4r/selector.c +72 -64
- data/lib/nio.rb +3 -3
- data/lib/nio/bytebuffer.rb +179 -132
- data/lib/nio/monitor.rb +64 -4
- data/lib/nio/selector.rb +36 -13
- data/lib/nio/version.rb +1 -1
- data/nio4r.gemspec +25 -19
- data/spec/nio/acceptables_spec.rb +6 -4
- data/spec/nio/bytebuffer_spec.rb +323 -51
- data/spec/nio/monitor_spec.rb +122 -79
- data/spec/nio/selectables/pipe_spec.rb +5 -1
- data/spec/nio/selectables/ssl_socket_spec.rb +15 -12
- data/spec/nio/selectables/tcp_socket_spec.rb +42 -31
- data/spec/nio/selectables/udp_socket_spec.rb +2 -0
- data/spec/nio/selector_spec.rb +10 -4
- data/spec/spec_helper.rb +24 -3
- data/spec/support/selectable_examples.rb +7 -5
- data/tasks/extension.rake +2 -0
- data/tasks/rspec.rake +2 -0
- data/tasks/rubocop.rake +2 -0
- metadata +18 -15
- data/.rubocop_todo.yml +0 -35
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "coveralls"
|
2
4
|
Coveralls.wear!
|
3
5
|
|
4
|
-
require "rubygems"
|
5
|
-
require "bundler/setup"
|
6
6
|
require "nio"
|
7
7
|
require "support/selectable_examples"
|
8
|
+
require "rspec/retry"
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.disable_monkey_patching!
|
12
|
+
config.verbose_retry = true
|
13
|
+
config.display_try_failure_messages = true
|
14
|
+
end
|
15
|
+
|
16
|
+
$current_tcp_port = 10_000
|
17
|
+
|
18
|
+
def next_available_tcp_port
|
19
|
+
loop do
|
20
|
+
$current_tcp_port += 1
|
21
|
+
|
22
|
+
begin
|
23
|
+
sock = Timeout.timeout(1) { TCPSocket.new("localhost", $current_tcp_port) }
|
24
|
+
rescue Errno::ECONNREFUSED
|
25
|
+
break $current_tcp_port
|
26
|
+
end
|
8
27
|
|
9
|
-
|
28
|
+
sock.close
|
29
|
+
end
|
30
|
+
end
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
RSpec.shared_context "an NIO selectable" do
|
2
4
|
let(:selector) { NIO::Selector.new }
|
3
5
|
|
4
|
-
it "selects readable objects" do
|
6
|
+
it "selects readable objects", retry: 5 do # retry: Flaky on OS X
|
5
7
|
monitor = selector.register(readable_subject, :r)
|
6
8
|
ready = selector.select(0)
|
7
9
|
expect(ready).to be_an Enumerable
|
@@ -9,7 +11,7 @@ RSpec.shared_context "an NIO selectable" do
|
|
9
11
|
end
|
10
12
|
|
11
13
|
it "does not select unreadable objects" do
|
12
|
-
|
14
|
+
selector.register(unreadable_subject, :r)
|
13
15
|
expect(selector.select(0)).to be_nil
|
14
16
|
end
|
15
17
|
|
@@ -21,7 +23,7 @@ RSpec.shared_context "an NIO selectable" do
|
|
21
23
|
end
|
22
24
|
|
23
25
|
it "does not select unwritable objects" do
|
24
|
-
|
26
|
+
selector.register(unwritable_subject, :w)
|
25
27
|
expect(selector.select(0)).to be_nil
|
26
28
|
end
|
27
29
|
end
|
@@ -49,8 +51,8 @@ RSpec.shared_context "an NIO bidirectional stream" do
|
|
49
51
|
let(:stream) { pair.first }
|
50
52
|
let(:peer) { pair.last }
|
51
53
|
|
52
|
-
it "selects readable and writable" do
|
53
|
-
|
54
|
+
it "selects readable and writable", retry: 5 do # retry: Flaky on OS X
|
55
|
+
selector.register(readable_subject, :rw)
|
54
56
|
selector.select(0) do |m|
|
55
57
|
expect(m.readiness).to eq(:rw)
|
56
58
|
end
|
data/tasks/extension.rake
CHANGED
data/tasks/rspec.rake
CHANGED
data/tasks/rubocop.rake
CHANGED
metadata
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nio4r
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Tony Arcieri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
|
-
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
|
-
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
21
|
requirements:
|
22
22
|
- - ">="
|
23
23
|
- !ruby/object:Gem::Version
|
@@ -26,21 +26,21 @@ dependencies:
|
|
26
26
|
type: :development
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
|
-
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
|
-
|
34
|
+
version_requirements: !ruby/object:Gem::Requirement
|
35
35
|
requirements:
|
36
36
|
- - ">="
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: '0'
|
39
39
|
prerelease: false
|
40
40
|
type: :development
|
41
|
-
description:
|
41
|
+
description: Cross-platform asynchronous I/O primitives for scalable network clients and servers. Inspired by the Java NIO API, but simplified for ease-of-use.
|
42
42
|
email:
|
43
|
-
-
|
43
|
+
- bascule@gmail.com
|
44
44
|
executables: []
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
@@ -48,10 +48,11 @@ files:
|
|
48
48
|
- ".gitignore"
|
49
49
|
- ".rspec"
|
50
50
|
- ".rubocop.yml"
|
51
|
-
- ".
|
51
|
+
- ".ruby-version"
|
52
52
|
- ".travis.yml"
|
53
53
|
- CHANGES.md
|
54
54
|
- Gemfile
|
55
|
+
- Guardfile
|
55
56
|
- LICENSE.txt
|
56
57
|
- README.md
|
57
58
|
- Rakefile
|
@@ -78,7 +79,9 @@ files:
|
|
78
79
|
- ext/nio4r/nio4r.h
|
79
80
|
- ext/nio4r/nio4r_ext.c
|
80
81
|
- ext/nio4r/org/nio4r/ByteBuffer.java
|
82
|
+
- ext/nio4r/org/nio4r/Monitor.java
|
81
83
|
- ext/nio4r/org/nio4r/Nio4r.java
|
84
|
+
- ext/nio4r/org/nio4r/Selector.java
|
82
85
|
- ext/nio4r/selector.c
|
83
86
|
- lib/nio.rb
|
84
87
|
- lib/nio/bytebuffer.rb
|
@@ -101,7 +104,7 @@ files:
|
|
101
104
|
- tasks/extension.rake
|
102
105
|
- tasks/rspec.rake
|
103
106
|
- tasks/rubocop.rake
|
104
|
-
homepage: https://github.com/
|
107
|
+
homepage: https://github.com/socketry/nio4r
|
105
108
|
licenses:
|
106
109
|
- MIT
|
107
110
|
metadata: {}
|
@@ -113,18 +116,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
116
|
requirements:
|
114
117
|
- - ">="
|
115
118
|
- !ruby/object:Gem::Version
|
116
|
-
version:
|
119
|
+
version: 2.2.2
|
117
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
121
|
requirements:
|
119
|
-
- - "
|
122
|
+
- - ">="
|
120
123
|
- !ruby/object:Gem::Version
|
121
|
-
version:
|
124
|
+
version: '0'
|
122
125
|
requirements: []
|
123
126
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.
|
127
|
+
rubygems_version: 2.6.8
|
125
128
|
signing_key:
|
126
129
|
specification_version: 4
|
127
|
-
summary:
|
130
|
+
summary: New IO for Ruby
|
128
131
|
test_files:
|
129
132
|
- spec/nio/acceptables_spec.rb
|
130
133
|
- spec/nio/bytebuffer_spec.rb
|
data/.rubocop_todo.yml
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
-
# on 2015-04-24 03:08:21 -0700 using RuboCop version 0.30.1.
|
3
|
-
# The point is for the user to remove these configuration records
|
4
|
-
# one by one as the offenses are removed from the code base.
|
5
|
-
# Note that changes in the inspected code, or installation of new
|
6
|
-
# versions of RuboCop, may require this file to be generated again.
|
7
|
-
|
8
|
-
# Offense count: 2
|
9
|
-
Lint/HandleExceptions:
|
10
|
-
Enabled: false
|
11
|
-
|
12
|
-
# Offense count: 3
|
13
|
-
Lint/Loop:
|
14
|
-
Enabled: false
|
15
|
-
|
16
|
-
# Offense count: 1
|
17
|
-
Lint/NonLocalExitFromIterator:
|
18
|
-
Enabled: false
|
19
|
-
|
20
|
-
# Offense count: 7
|
21
|
-
Lint/UselessAssignment:
|
22
|
-
Enabled: false
|
23
|
-
|
24
|
-
# Offense count: 1
|
25
|
-
# Configuration parameters: SupportedStyles, IndentOneStep.
|
26
|
-
Style/CaseIndentation:
|
27
|
-
IndentWhenRelativeTo: end
|
28
|
-
|
29
|
-
# Offense count: 1
|
30
|
-
Style/Documentation:
|
31
|
-
Enabled: false
|
32
|
-
|
33
|
-
# Offense count: 2
|
34
|
-
Style/RescueModifier:
|
35
|
-
Enabled: false
|