nio4r 2.0.0.pre → 2.0.0
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 +4 -21
- data/CHANGES.md +75 -42
- data/Gemfile +11 -3
- data/Guardfile +10 -0
- data/LICENSE.txt +1 -1
- data/README.md +32 -136
- data/Rakefile +2 -0
- data/examples/echo_server.rb +1 -0
- data/ext/libev/Changes +4 -13
- data/ext/libev/ev.c +100 -74
- data/ext/libev/ev.h +3 -3
- 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 +2 -10
- data/ext/nio4r/monitor.c +93 -46
- data/ext/nio4r/nio4r.h +5 -15
- 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 +52 -52
- 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 +15 -11
- 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(0.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,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nio4r
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0
|
4
|
+
version: 2.0.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: 2016-
|
11
|
+
date: 2016-12-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -38,9 +38,10 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description:
|
41
|
+
description: Cross-platform asynchronous I/O primitives for scalable network clients
|
42
|
+
and servers. Inspired by the Java NIO API, but simplified for ease-of-use.
|
42
43
|
email:
|
43
|
-
-
|
44
|
+
- bascule@gmail.com
|
44
45
|
executables: []
|
45
46
|
extensions:
|
46
47
|
- ext/nio4r/extconf.rb
|
@@ -49,10 +50,11 @@ files:
|
|
49
50
|
- ".gitignore"
|
50
51
|
- ".rspec"
|
51
52
|
- ".rubocop.yml"
|
52
|
-
- ".
|
53
|
+
- ".ruby-version"
|
53
54
|
- ".travis.yml"
|
54
55
|
- CHANGES.md
|
55
56
|
- Gemfile
|
57
|
+
- Guardfile
|
56
58
|
- LICENSE.txt
|
57
59
|
- README.md
|
58
60
|
- Rakefile
|
@@ -79,7 +81,9 @@ files:
|
|
79
81
|
- ext/nio4r/nio4r.h
|
80
82
|
- ext/nio4r/nio4r_ext.c
|
81
83
|
- ext/nio4r/org/nio4r/ByteBuffer.java
|
84
|
+
- ext/nio4r/org/nio4r/Monitor.java
|
82
85
|
- ext/nio4r/org/nio4r/Nio4r.java
|
86
|
+
- ext/nio4r/org/nio4r/Selector.java
|
83
87
|
- ext/nio4r/selector.c
|
84
88
|
- lib/nio.rb
|
85
89
|
- lib/nio/bytebuffer.rb
|
@@ -101,7 +105,7 @@ files:
|
|
101
105
|
- tasks/extension.rake
|
102
106
|
- tasks/rspec.rake
|
103
107
|
- tasks/rubocop.rake
|
104
|
-
homepage: https://github.com/
|
108
|
+
homepage: https://github.com/socketry/nio4r
|
105
109
|
licenses:
|
106
110
|
- MIT
|
107
111
|
metadata: {}
|
@@ -113,18 +117,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
117
|
requirements:
|
114
118
|
- - ">="
|
115
119
|
- !ruby/object:Gem::Version
|
116
|
-
version:
|
120
|
+
version: 2.2.2
|
117
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
122
|
requirements:
|
119
|
-
- - "
|
123
|
+
- - ">="
|
120
124
|
- !ruby/object:Gem::Version
|
121
|
-
version:
|
125
|
+
version: '0'
|
122
126
|
requirements: []
|
123
127
|
rubyforge_project:
|
124
|
-
rubygems_version: 2.
|
128
|
+
rubygems_version: 2.6.8
|
125
129
|
signing_key:
|
126
130
|
specification_version: 4
|
127
|
-
summary:
|
131
|
+
summary: New IO for Ruby
|
128
132
|
test_files:
|
129
133
|
- spec/nio/acceptables_spec.rb
|
130
134
|
- 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
|