em-rocketio-linda-client 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +4 -0
- data/lib/em-rocketio-linda-client/client.rb +18 -4
- data/lib/em-rocketio-linda-client/version.rb +1 -1
- data/sample/sample_blocking.rb +3 -1
- data/test/test_blocking_read_take.rb +11 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c354cbf30aa56faacf8b95a45a48f1c77fa5af7
|
4
|
+
data.tar.gz: eb57bc2228a388b68c65c223fe02b8957376b380
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 89e783fd0488ef8f09862f1c2fe6ae240e1e072b3ff4a07deacb5d5f56eb9f9694cb576327d8fc934e9e0364fed5baab1040a6383211776cb110042bc8040d7e
|
7
|
+
data.tar.gz: 37a84a3dcb573314fef925e0d76f5fed1c995842c5f6e2ae460a48efad0e11afe7bf68e0343b024a92482f25071af2fe331ba8cb561695864b3fcc5ffe85555c
|
data/History.txt
CHANGED
@@ -41,7 +41,7 @@ module EM
|
|
41
41
|
unless [Hash, Array].include? tuple.class
|
42
42
|
raise ArgumentError, "tuple must be Array or Hash"
|
43
43
|
end
|
44
|
-
callback_id =
|
44
|
+
callback_id = make_callback_id
|
45
45
|
if block_given?
|
46
46
|
@linda.io.once "__linda_read_callback_#{callback_id}" do |data|
|
47
47
|
block.call(data['tuple'], TupleInfo.new(data['info']))
|
@@ -64,7 +64,7 @@ module EM
|
|
64
64
|
unless [Hash, Array].include? tuple.class
|
65
65
|
raise ArgumentError, "tuple must be Array or Hash"
|
66
66
|
end
|
67
|
-
callback_id =
|
67
|
+
callback_id = make_callback_id
|
68
68
|
if block_given?
|
69
69
|
@linda.io.once "__linda_take_callback_#{callback_id}" do |data|
|
70
70
|
block.call data['tuple'], TupleInfo.new(data['info'])
|
@@ -88,7 +88,7 @@ module EM
|
|
88
88
|
raise ArgumentError, "tuple must be Array or Hash"
|
89
89
|
end
|
90
90
|
return unless block_given?
|
91
|
-
callback_id =
|
91
|
+
callback_id = make_callback_id
|
92
92
|
@linda.io.on "__linda_watch_callback_#{callback_id}" do |data|
|
93
93
|
block.call data['tuple'], TupleInfo.new(data['info'])
|
94
94
|
end
|
@@ -99,7 +99,7 @@ module EM
|
|
99
99
|
unless [Hash, Array].include? tuple.class
|
100
100
|
raise ArgumentError, "tuple must be Array or Hash"
|
101
101
|
end
|
102
|
-
callback_id =
|
102
|
+
callback_id = make_callback_id
|
103
103
|
if block_given?
|
104
104
|
@linda.io.once "__linda_list_callback_#{callback_id}" do |list|
|
105
105
|
block.call list
|
@@ -107,6 +107,20 @@ module EM
|
|
107
107
|
@linda.io.push "__linda_list", [@name, tuple, callback_id]
|
108
108
|
return
|
109
109
|
end
|
110
|
+
results = nil
|
111
|
+
@linda.io.once "__linda_list_callback_#{callback_id}" do |list|
|
112
|
+
results = list
|
113
|
+
end
|
114
|
+
@linda.io.push "__linda_list", [@name, tuple, callback_id]
|
115
|
+
while results == nil do
|
116
|
+
sleep 0.1
|
117
|
+
end
|
118
|
+
return results
|
119
|
+
end
|
120
|
+
|
121
|
+
private
|
122
|
+
def make_callback_id
|
123
|
+
"#{Time.now.to_i}#{Time.now.usec}_#{rand(1000000).to_i}"
|
110
124
|
end
|
111
125
|
|
112
126
|
end
|
data/sample/sample_blocking.rb
CHANGED
@@ -71,30 +71,28 @@ class TestBlockingReadTake < MiniTest::Test
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def test_blocking_list
|
74
|
-
ts_name = "
|
75
|
-
_tuple1 = ["a", "b", "c"]
|
76
|
-
_tuple2 = ["a", "b"]
|
77
|
-
_tuple3 = ["a", "b", "c", 1234]
|
74
|
+
ts_name = "ts_blocking_list_#{rand Time.now.to_i}"
|
75
|
+
_tuple1 = ["blocking", "a", "b", "c"]
|
76
|
+
_tuple2 = ["blocking", "a", "b"]
|
77
|
+
_tuple3 = ["blocking", "a", "b", "c", 1234]
|
78
78
|
_result1 = nil
|
79
79
|
_result2 = nil
|
80
80
|
EM::run do
|
81
81
|
client = EM::RocketIO::Linda::Client.new App.url
|
82
82
|
ts = client.tuplespace[ts_name]
|
83
83
|
client.io.on :connect do
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
p _result2
|
84
|
+
EM::defer do
|
85
|
+
ts.write _tuple1
|
86
|
+
ts.write _tuple2
|
87
|
+
ts.write _tuple3
|
88
|
+
_result1 = ts.list ["blocking", "a", "b"]
|
89
|
+
_result2 = ts.list ["blocking", "a", "b", "c"]
|
90
|
+
end
|
92
91
|
end
|
93
92
|
|
94
93
|
EM::defer do
|
95
94
|
50.times do
|
96
95
|
sleep 0.1
|
97
|
-
puts "waiting list"
|
98
96
|
break if _result2
|
99
97
|
end
|
100
98
|
EM::add_timer 1 do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: em-rocketio-linda-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sho Hashimoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|