nio4r 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1b801ac687bb5098220b7d2b870f84d172cdcd0683c50175006196e7ab9f5021
4
- data.tar.gz: 93301d044d3bb5fe7b7e9db9b1ab7d0b683770a22adda61b6e6ccb60bbe1a137
3
+ metadata.gz: cfaa168a1d757e1242d427f89189e39f424039c30fe6a384194166ae7a6e6694
4
+ data.tar.gz: fe2f130edf1d7963672302b21210a18d915583d096c1721b65e8ec9dc702b5ce
5
5
  SHA512:
6
- metadata.gz: 000f6a6ebe2acb74581d0c4976c0fc46ed2ae2baeaea6b18622c7b7105567e3734517429867e9b1bed9df5e8b320430d4dff505f98e817d9c6248eca6a7ccdba
7
- data.tar.gz: 988ee869b08ea7d91c5383ee28c505db0e595eec35c98513b3468e1ecec66224894514e352db810cc1143b797c9c6af714ebd3d3eee90291f036e09ad4a28ccd
6
+ metadata.gz: 0a195646b2139336075368785eeb77e2de30f700c0845cd14696572685dcfeded9e023761414ed01485e0d617ce96790c6e97cc810bfb95ed600e44cf467ac55
7
+ data.tar.gz: fa758ef58d38dbe41c44936998d00830e9058b1daef51fe30f551b15ed2148121d5c536dfee8c2ac9c8f064000b8df170b30cb5f87fbc7c4cb6348bd92d3ec15
data/CHANGES.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 2.3.0 (2018-03-15)
2
+
3
+ * [#183](https://github.com/socketry/nio4r/pull/183)
4
+ Allow `Monitor#interests` to be nil
5
+ ([@ioquatix])
6
+
1
7
  ## 2.2.0 (2017-12-27)
2
8
 
3
9
  * [#151](https://github.com/socketry/nio4r/pull/151)
@@ -206,3 +212,4 @@
206
212
  [@larskanis]: https://github.com/larskanis
207
213
  [@HoneyryderChuck]: https://github.com/HoneyryderChuck
208
214
  [@tompng]: https://github.com/tompng
215
+ [@ioquatix]: https://github.com/ioquatix
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011-2017 Tony Arcieri
1
+ Copyright (c) 2011-2018 Tony Arcieri
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -95,7 +95,7 @@ to maintain a large codebase.
95
95
 
96
96
  ## License
97
97
 
98
- Copyright (c) 2011-2017 Tony Arcieri. Distributed under the MIT License.
98
+ Copyright (c) 2011-2018 Tony Arcieri. Distributed under the MIT License.
99
99
  See [LICENSE.txt] for further details.
100
100
 
101
101
  Includes libev 4.24. Copyright (c) 2007-2016 Marc Alexander Lehmann.
@@ -163,7 +163,11 @@ static VALUE NIO_Monitor_interests(VALUE self)
163
163
 
164
164
  static VALUE NIO_Monitor_set_interests(VALUE self, VALUE interests)
165
165
  {
166
- NIO_Monitor_update_interests(self, NIO_Monitor_symbol2interest(interests));
166
+ if(NIL_P(interests)) {
167
+ NIO_Monitor_update_interests(self, 0);
168
+ } else {
169
+ NIO_Monitor_update_interests(self, NIO_Monitor_symbol2interest(interests));
170
+ }
167
171
 
168
172
  return rb_ivar_get(self, rb_intern("interests"));
169
173
  }
@@ -292,9 +296,11 @@ static void NIO_Monitor_update_interests(VALUE self, int interests)
292
296
  rb_ivar_set(self, rb_intern("interests"), Qnil);
293
297
  }
294
298
 
295
- monitor->interests = interests;
299
+ if(monitor->interests != interests) {
300
+ monitor->interests = interests;
296
301
 
297
- ev_io_stop(monitor->selector->ev_loop, &monitor->ev_io);
298
- ev_io_set(&monitor->ev_io, monitor->ev_io.fd, monitor->interests);
299
- ev_io_start(monitor->selector->ev_loop, &monitor->ev_io);
302
+ ev_io_stop(monitor->selector->ev_loop, &monitor->ev_io);
303
+ ev_io_set(&monitor->ev_io, monitor->ev_io.fd, monitor->interests);
304
+ ev_io_start(monitor->selector->ev_loop, &monitor->ev_io);
305
+ }
300
306
  }
@@ -62,7 +62,12 @@ public class Monitor extends RubyObject {
62
62
  Ruby ruby = context.getRuntime();
63
63
  SelectableChannel channel = (SelectableChannel)io.getChannel();
64
64
 
65
- key.interestOps(Nio4r.symbolToInterestOps(ruby, channel, interests));
65
+ if(interests != context.nil) {
66
+ key.interestOps(Nio4r.symbolToInterestOps(ruby, channel, interests));
67
+ } else {
68
+ key.interestOps(0);
69
+ }
70
+
66
71
  this.interests = interests;
67
72
 
68
73
  return this.interests;
@@ -26,12 +26,12 @@ module NIO
26
26
 
27
27
  # Replace the existing interest set with a new one
28
28
  #
29
- # @param interests [:r, :w, :rw] I/O readiness we're interested in (read/write/readwrite)
29
+ # @param interests [:r, :w, :rw, nil] I/O readiness we're interested in (read/write/readwrite)
30
30
  #
31
31
  # @return [Symbol] new interests
32
32
  def interests=(interests)
33
33
  raise EOFError, "monitor is closed" if closed?
34
- raise ArgumentError, "bad interests: #{interests}" unless %i[r w rw].include?(interests)
34
+ raise ArgumentError, "bad interests: #{interests}" unless [:r, :w, :rw, nil].include?(interests)
35
35
 
36
36
  @interests = interests
37
37
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NIO
4
- VERSION = "2.2.0".freeze
4
+ VERSION = "2.3.0".freeze
5
5
  end
@@ -29,6 +29,12 @@ RSpec.describe NIO::Monitor do
29
29
  end
30
30
 
31
31
  describe "#interests=" do
32
+ it "can set interests to nil" do
33
+ expect(monitor.interests).not_to eq(nil)
34
+ monitor.interests = nil
35
+ expect(monitor.interests).to eq(nil)
36
+ end
37
+
32
38
  it "changes the interest set" do
33
39
  expect(monitor.interests).not_to eq(:w)
34
40
  monitor.interests = :w
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.2.0
4
+ version: 2.3.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: 2017-12-27 00:00:00.000000000 Z
11
+ date: 2018-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  version: '0'
126
126
  requirements: []
127
127
  rubyforge_project:
128
- rubygems_version: 2.7.3
128
+ rubygems_version: 2.7.4
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: New IO for Ruby