nio4r 0.2.1-java → 0.2.2-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ 0.2.2
2
+ -----
3
+ * Raise IOError if asked to wake up a closed selector
4
+
1
5
  0.2.1
2
6
  -----
3
7
  * Implement wakeup mechanism using raw pipes instead of ev_async, since
@@ -406,6 +406,10 @@ static VALUE NIO_Selector_wakeup(VALUE self)
406
406
  struct NIO_Selector *selector;
407
407
  Data_Get_Struct(self, struct NIO_Selector, selector);
408
408
 
409
+ if(selector->closed) {
410
+ rb_raise(rb_eIOError, "selector is closed");
411
+ }
412
+
409
413
  write(selector->wakeup_writer, "\0", 1);
410
414
 
411
415
  return Qnil;
@@ -118,6 +118,7 @@ module NIO
118
118
 
119
119
  # Wake up the other thread that's currently blocking on this selector
120
120
  def wakeup
121
+ raise IOError, "selector is closed" if closed?
121
122
  @java_selector.wakeup
122
123
  nil
123
124
  end
@@ -98,7 +98,12 @@ module NIO
98
98
  selected.size
99
99
  end
100
100
 
101
- # Wake up other threads waiting on this selector
101
+ # Wake up a thread that's in the middle of selecting on this selector, if
102
+ # any such thread exists.
103
+ #
104
+ # Invoking this method more than once between two successive select calls
105
+ # has the same effect as invoking it just once. In other words, it provides
106
+ # level-triggered behavior.
102
107
  def wakeup
103
108
  # Send the selector a signal in the form of writing data to a pipe
104
109
  @waker << "\0"
@@ -1,3 +1,3 @@
1
1
  module NIO
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -15,8 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = NIO::VERSION
17
17
  # gem.extensions = ["ext/nio4r/extconf.rb"]
18
- gem.platform = 'java'
19
-
18
+ gem.platform = 'java'
20
19
  gem.add_development_dependency "rake-compiler", "~> 0.7.9"
21
20
  gem.add_development_dependency "rake"
22
21
  gem.add_development_dependency "rspec", "~> 2.7.0"
@@ -30,25 +30,25 @@ describe NIO::Selector do
30
30
  monitor.should be_closed
31
31
  end
32
32
 
33
- context "select" do
34
- it "waits for a timeout when selecting" do
35
- reader, writer = IO.pipe
36
- monitor = subject.register(reader, :r)
37
-
38
- payload = "hi there"
39
- writer << payload
40
-
41
- timeout = 0.5
42
- started_at = Time.now
43
- subject.select(timeout).should include monitor
44
- (Time.now - started_at).should be_within(TIMEOUT_PRECISION).of(0)
45
- reader.read_nonblock(payload.size)
46
-
47
- started_at = Time.now
48
- subject.select(timeout).should be_nil
49
- (Time.now - started_at).should be_within(TIMEOUT_PRECISION).of(timeout)
50
- end
33
+ it "waits for a timeout when selecting" do
34
+ reader, writer = IO.pipe
35
+ monitor = subject.register(reader, :r)
36
+
37
+ payload = "hi there"
38
+ writer << payload
51
39
 
40
+ timeout = 0.5
41
+ started_at = Time.now
42
+ subject.select(timeout).should include monitor
43
+ (Time.now - started_at).should be_within(TIMEOUT_PRECISION).of(0)
44
+ reader.read_nonblock(payload.size)
45
+
46
+ started_at = Time.now
47
+ subject.select(timeout).should be_nil
48
+ (Time.now - started_at).should be_within(TIMEOUT_PRECISION).of(timeout)
49
+ end
50
+
51
+ context "wakeup" do
52
52
  it "wakes up if signaled to from another thread" do
53
53
  pipe, _ = IO.pipe
54
54
  subject.register(pipe, :r)
@@ -65,6 +65,13 @@ describe NIO::Selector do
65
65
 
66
66
  thread.value.should be_within(TIMEOUT_PRECISION).of(timeout)
67
67
  end
68
+
69
+ it "raises IOError if asked to wake up a closed selector" do
70
+ subject.close
71
+ subject.should be_closed
72
+
73
+ expect { subject.wakeup }.to raise_exception IOError
74
+ end
68
75
  end
69
76
 
70
77
  context "select_each" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nio4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: java
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-01-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake-compiler
16
- requirement: &70225282552520 !ruby/object:Gem::Requirement
16
+ requirement: &70302856516460 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.7.9
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70225282552520
24
+ version_requirements: *70302856516460
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70225282551940 !ruby/object:Gem::Requirement
27
+ requirement: &70302856515580 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70225282551940
35
+ version_requirements: *70302856515580
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70225282551240 !ruby/object:Gem::Requirement
38
+ requirement: &70302856514260 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 2.7.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70225282551240
46
+ version_requirements: *70302856514260
47
47
  description: New IO for Ruby
48
48
  email:
49
49
  - tony.arcieri@gmail.com