concurrent_worker 0.4.6 → 0.4.7
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/concurrent_worker/version.rb +1 -1
- data/lib/concurrent_worker/worker.rb +13 -10
- data/lib/concurrent_worker/workerpool.rb +7 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97373cc494de938ae3ef205c054bde0b1b83d24c144261140216243b1fccd5ac
|
4
|
+
data.tar.gz: 8163bd6861fd4492e10c4d2ce49bf63c53840235b375d87377bdc9bc13bf8ace
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63178d2cc57d866eb01487993e9effc9cfc85e17d32db68e1cc2be97b30a21323ee1f7a2a92b84cef3c207d5b1861ca9d697c0ed921a635ed49a164d52f9963f
|
7
|
+
data.tar.gz: 03053e5a1c1187f777287e801a2a18583728d29d9bb0251fdaf06c9ee8796a0715ffd70524d585e2992f7317b8b2f74f8d1756b17880765c3d0f82f86ac35944
|
data/Gemfile.lock
CHANGED
@@ -29,6 +29,7 @@ module ConcurrentWorker
|
|
29
29
|
@retired_callbacks = []
|
30
30
|
|
31
31
|
@snd_queue_max = @options[:snd_queue_max] || 2
|
32
|
+
@req_mutex = Mutex.new
|
32
33
|
@req_counter = RequestCounter.new
|
33
34
|
@options[:result_callback_interrupt] ||= :immediate
|
34
35
|
@options[:retired_callback_interrupt] ||= :immediate
|
@@ -163,16 +164,18 @@ module ConcurrentWorker
|
|
163
164
|
end
|
164
165
|
|
165
166
|
def req(*args, &work_block)
|
166
|
-
|
167
|
-
run
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
167
|
+
@req_mutex.synchronize do
|
168
|
+
unless @state == :run
|
169
|
+
run
|
170
|
+
end
|
171
|
+
@req_counter.wait_until_less_than(@snd_queue_max) if @snd_queue_max > 0
|
172
|
+
begin
|
173
|
+
@req_counter.push([args, work_block])
|
174
|
+
send_req([args, work_block])
|
175
|
+
true
|
176
|
+
rescue ClosedQueueError, IOError
|
177
|
+
false
|
178
|
+
end
|
176
179
|
end
|
177
180
|
end
|
178
181
|
|
@@ -77,6 +77,7 @@ module ConcurrentWorker
|
|
77
77
|
@result_callbacks = []
|
78
78
|
|
79
79
|
@snd_queue_max = @options[:snd_queue_max]||2
|
80
|
+
@req_mutex = Mutex.new
|
80
81
|
@req_counter = RequestCounter.new
|
81
82
|
|
82
83
|
@snd_queue = Queue.new
|
@@ -142,10 +143,12 @@ module ConcurrentWorker
|
|
142
143
|
end
|
143
144
|
|
144
145
|
def req(*args, &work_block)
|
145
|
-
@
|
146
|
-
|
147
|
-
|
148
|
-
|
146
|
+
@req_mutex.synchronize do
|
147
|
+
@req_counter.wait_until_less_than(@max_num * @snd_queue_max) if @snd_queue_max > 0
|
148
|
+
@req_counter.push(true)
|
149
|
+
@snd_queue.push([args, work_block])
|
150
|
+
true
|
151
|
+
end
|
149
152
|
end
|
150
153
|
|
151
154
|
def join
|