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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +0 -1
  3. data/.rubocop.yml +31 -38
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +4 -21
  6. data/CHANGES.md +75 -42
  7. data/Gemfile +11 -3
  8. data/Guardfile +10 -0
  9. data/LICENSE.txt +1 -1
  10. data/README.md +32 -136
  11. data/Rakefile +2 -0
  12. data/examples/echo_server.rb +1 -0
  13. data/ext/libev/Changes +4 -13
  14. data/ext/libev/ev.c +100 -74
  15. data/ext/libev/ev.h +3 -3
  16. data/ext/libev/ev_epoll.c +6 -3
  17. data/ext/libev/ev_kqueue.c +8 -4
  18. data/ext/libev/ev_poll.c +6 -3
  19. data/ext/libev/ev_port.c +8 -4
  20. data/ext/libev/ev_select.c +4 -2
  21. data/ext/nio4r/bytebuffer.c +265 -257
  22. data/ext/nio4r/extconf.rb +2 -10
  23. data/ext/nio4r/monitor.c +93 -46
  24. data/ext/nio4r/nio4r.h +5 -15
  25. data/ext/nio4r/org/nio4r/ByteBuffer.java +193 -209
  26. data/ext/nio4r/org/nio4r/Monitor.java +164 -0
  27. data/ext/nio4r/org/nio4r/Nio4r.java +13 -391
  28. data/ext/nio4r/org/nio4r/Selector.java +278 -0
  29. data/ext/nio4r/selector.c +52 -52
  30. data/lib/nio.rb +3 -3
  31. data/lib/nio/bytebuffer.rb +179 -132
  32. data/lib/nio/monitor.rb +64 -4
  33. data/lib/nio/selector.rb +36 -13
  34. data/lib/nio/version.rb +1 -1
  35. data/nio4r.gemspec +25 -19
  36. data/spec/nio/acceptables_spec.rb +6 -4
  37. data/spec/nio/bytebuffer_spec.rb +323 -51
  38. data/spec/nio/monitor_spec.rb +122 -79
  39. data/spec/nio/selectables/pipe_spec.rb +5 -1
  40. data/spec/nio/selectables/ssl_socket_spec.rb +15 -12
  41. data/spec/nio/selectables/tcp_socket_spec.rb +42 -31
  42. data/spec/nio/selectables/udp_socket_spec.rb +2 -0
  43. data/spec/nio/selector_spec.rb +10 -4
  44. data/spec/spec_helper.rb +24 -3
  45. data/spec/support/selectable_examples.rb +7 -5
  46. data/tasks/extension.rake +2 -0
  47. data/tasks/rspec.rake +2 -0
  48. data/tasks/rubocop.rake +2 -0
  49. metadata +15 -11
  50. data/.rubocop_todo.yml +0 -35
@@ -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
- RSpec.configure(&:disable_monkey_patching!)
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
- monitor = selector.register(unreadable_subject, :r)
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
- monitor = selector.register(unwritable_subject, :w)
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
- monitor = selector.register(readable_subject, :rw)
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  if defined? JRUBY_VERSION
2
4
  require "rake/javaextensiontask"
3
5
  Rake::JavaExtensionTask.new("nio4r_ext") do |ext|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rspec/core/rake_task"
2
4
 
3
5
  RSpec::Core::RakeTask.new
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rubocop/rake_task"
2
4
 
3
5
  RuboCop::RakeTask.new
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.pre
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-05 00:00:00.000000000 Z
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: New IO for Ruby
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
- - tony.arcieri@gmail.com
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
- - ".rubocop_todo.yml"
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/celluloid/nio4r
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: '0'
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: 1.3.1
125
+ version: '0'
122
126
  requirements: []
123
127
  rubyforge_project:
124
- rubygems_version: 2.5.1
128
+ rubygems_version: 2.6.8
125
129
  signing_key:
126
130
  specification_version: 4
127
- summary: NIO provides a high performance selector API for monitoring IO objects
131
+ summary: New IO for Ruby
128
132
  test_files:
129
133
  - spec/nio/acceptables_spec.rb
130
134
  - spec/nio/bytebuffer_spec.rb
@@ -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