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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a15ca83f00ae8e5e6bc71edc2da3216e5b14bd74
4
- data.tar.gz: dfa050a61c09993ae3bc68d9ab424bffb0654c94
3
+ metadata.gz: 9c354cbf30aa56faacf8b95a45a48f1c77fa5af7
4
+ data.tar.gz: eb57bc2228a388b68c65c223fe02b8957376b380
5
5
  SHA512:
6
- metadata.gz: 4e03ca5d2b34da1c771bb9e35dba97e17b07421c1bcd5c60763f213f18266ee82cda8ef1b6a72e0548e6e6a7416f9fa1d57517358f0e1c9b1be2f21b307e8d92
7
- data.tar.gz: 8ca32be12723bfb4e55c81995a7babca40295ee31c92b7d52916efbb00abd7918b8642863aa1422c7021372770f4c2132d9f39f4aa96cb782079a3b7f54ba934
6
+ metadata.gz: 89e783fd0488ef8f09862f1c2fe6ae240e1e072b3ff4a07deacb5d5f56eb9f9694cb576327d8fc934e9e0364fed5baab1040a6383211776cb110042bc8040d7e
7
+ data.tar.gz: 37a84a3dcb573314fef925e0d76f5fed1c995842c5f6e2ae460a48efad0e11afe7bf68e0343b024a92482f25071af2fe331ba8cb561695864b3fcc5ffe85555c
@@ -1,3 +1,7 @@
1
+ === 1.1.1 2013-11-20
2
+
3
+ * blocking-style TupleSpace#list #5
4
+
1
5
  === 1.1.0 2013-11-19
2
6
 
3
7
  * add TupleSpace#list #5
@@ -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 = "#{Time.now.to_i}#{Time.now.usec}_#{rand(1000000).to_i}"
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 = "#{Time.now.to_i}#{Time.now.usec}_#{rand(1000000).to_i}"
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 = "#{Time.now.to_i}#{Time.now.usec}_#{rand(1000000).to_i}"
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 = "#{Time.now.to_i}#{Time.now.usec}_#{rand(1000000).to_i}"
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
@@ -2,7 +2,7 @@ module EM
2
2
  module RocketIO
3
3
  module Linda
4
4
  class Client
5
- VERSION = "1.1.0"
5
+ VERSION = "1.1.1"
6
6
  end
7
7
  end
8
8
  end
@@ -17,8 +17,10 @@ EM::run do
17
17
 
18
18
  EM::defer do
19
19
  loop do
20
- tuple = ts.take [1,2]
20
+ tuple = ts.take [1,2] ## read tuple([1,2]) and delete
21
21
  puts "blocking take #{tuple}"
22
+ list = ts.list [1,2]
23
+ puts "#{list.size} tuples exists."
22
24
  end
23
25
  end
24
26
 
@@ -71,30 +71,28 @@ class TestBlockingReadTake < MiniTest::Test
71
71
  end
72
72
 
73
73
  def test_blocking_list
74
- ts_name = "ts_blocking_read_#{rand Time.now.to_i}"
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
- ts.write _tuple1
85
- ts.write _tuple2
86
- ts.write _tuple3
87
-
88
- _result1 = ts.list ["a", "b"]
89
- p _result1
90
- _result2 = ts.list ["a", "b", "c"]
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.0
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-19 00:00:00.000000000 Z
11
+ date: 2013-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler