ichannel 3.0.3 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +1 -0
- data/ChangeLog.txt +11 -0
- data/lib/ichannel/version.rb +1 -1
- data/lib/ichannel.rb +10 -2
- data/test/ichannel_class_test.rb +15 -0
- metadata +5 -4
data/.yardopts
CHANGED
data/ChangeLog.txt
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
== HEAD
|
2
|
+
* Add IChannel#empty?.
|
3
|
+
|
4
|
+
IChannel#empty? returns true when the channel is empty(nothing to read).
|
5
|
+
|
6
|
+
* Micro speed improvement on #write!, & #recv! operations.
|
7
|
+
|
8
|
+
By passing nil instead of creating two empty arrays for every read/write
|
9
|
+
operation we should see a very small improvement in their performance.
|
10
|
+
|
11
|
+
* Add ChangeLog.txt
|
data/lib/ichannel/version.rb
CHANGED
data/lib/ichannel.rb
CHANGED
@@ -68,7 +68,7 @@ class IChannel
|
|
68
68
|
if @writer.closed?
|
69
69
|
raise IOError, 'The channel cannot be written to (closed).'
|
70
70
|
end
|
71
|
-
_, writable, _ = IO.select
|
71
|
+
_, writable, _ = IO.select nil, [@writer], nil, timeout
|
72
72
|
if writable
|
73
73
|
writable[0].send @serializer.dump(object), 0
|
74
74
|
else
|
@@ -114,7 +114,7 @@ class IChannel
|
|
114
114
|
if @reader.closed?
|
115
115
|
raise IOError, 'The channel cannot be read from (closed).'
|
116
116
|
end
|
117
|
-
readable, _ = IO.select [@reader],
|
117
|
+
readable, _ = IO.select [@reader], nil, nil, timeout
|
118
118
|
if readable
|
119
119
|
msg, _ = readable[0].recvmsg
|
120
120
|
@serializer.load msg
|
@@ -123,4 +123,12 @@ class IChannel
|
|
123
123
|
end
|
124
124
|
end
|
125
125
|
alias_method :get!, :recv!
|
126
|
+
|
127
|
+
#
|
128
|
+
# @return [Boolean]
|
129
|
+
# Returns true if the channel is empty (nothing to read).
|
130
|
+
#
|
131
|
+
def empty?
|
132
|
+
! IO.select [@reader], nil, nil, 0.1
|
133
|
+
end
|
126
134
|
end
|
data/test/ichannel_class_test.rb
CHANGED
@@ -39,4 +39,19 @@ class IChannelTest < Test::Unit::TestCase
|
|
39
39
|
assert_equal %w(a), @channel.get
|
40
40
|
assert_equal %w(b), @channel.get
|
41
41
|
end
|
42
|
+
|
43
|
+
def test_empty_on_empty_channel
|
44
|
+
assert @channel.empty?
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_empty_on_populated_channel
|
48
|
+
@channel.put %w(a)
|
49
|
+
refute @channel.empty?
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_empty_on_emptied_channel
|
53
|
+
@channel.put %w(a)
|
54
|
+
@channel.get
|
55
|
+
assert @channel.empty?
|
56
|
+
end
|
42
57
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ichannel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-27 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: ! "A modern and easy-to-use interprocess communication \n primitive."
|
15
15
|
email:
|
@@ -21,6 +21,7 @@ files:
|
|
21
21
|
- .gitignore
|
22
22
|
- .travis.yml
|
23
23
|
- .yardopts
|
24
|
+
- ChangeLog.txt
|
24
25
|
- Gemfile
|
25
26
|
- LICENSE.txt
|
26
27
|
- README.md
|
@@ -44,7 +45,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
44
45
|
version: '0'
|
45
46
|
segments:
|
46
47
|
- 0
|
47
|
-
hash:
|
48
|
+
hash: 752004929419956183
|
48
49
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
50
|
none: false
|
50
51
|
requirements:
|
@@ -53,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
53
54
|
version: '0'
|
54
55
|
segments:
|
55
56
|
- 0
|
56
|
-
hash:
|
57
|
+
hash: 752004929419956183
|
57
58
|
requirements: []
|
58
59
|
rubyforge_project:
|
59
60
|
rubygems_version: 1.8.23
|