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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d45c579c92501c9f744e23a18e20fd5468fd24626cc06c0df93dd5316aede0a
4
- data.tar.gz: abc399a8a010438d48d7b04a0d48b9e188401043771c74a7621e705545aa42fe
3
+ metadata.gz: 97373cc494de938ae3ef205c054bde0b1b83d24c144261140216243b1fccd5ac
4
+ data.tar.gz: 8163bd6861fd4492e10c4d2ce49bf63c53840235b375d87377bdc9bc13bf8ace
5
5
  SHA512:
6
- metadata.gz: 2662546be40b1ab2f3b5f8336e6f1a86c552647d876db545b070773c0404e95aecbbee36ae0b974badae6362b3d40d42f9dead2a4025c6edeab5417208ed0db1
7
- data.tar.gz: 2a5f70d09c5c0588512c27320ecfadf3b281a2317c33d5bc3be2db128aa1fe01d2ceef1df68d43cd4a81b9b8384d2548e38019ddb144c2d139d3a8475ea47223
6
+ metadata.gz: 63178d2cc57d866eb01487993e9effc9cfc85e17d32db68e1cc2be97b30a21323ee1f7a2a92b84cef3c207d5b1861ca9d697c0ed921a635ed49a164d52f9963f
7
+ data.tar.gz: 03053e5a1c1187f777287e801a2a18583728d29d9bb0251fdaf06c9ee8796a0715ffd70524d585e2992f7317b8b2f74f8d1756b17880765c3d0f82f86ac35944
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- concurrent_worker (0.4.6)
4
+ concurrent_worker (0.4.7)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,3 +1,3 @@
1
1
  module ConcurrentWorker
2
- VERSION = "0.4.6"
2
+ VERSION = "0.4.7"
3
3
  end
@@ -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
- unless @state == :run
167
- run
168
- end
169
- @req_counter.wait_until_less_than(@snd_queue_max) if @snd_queue_max > 0
170
- begin
171
- @req_counter.push([args, work_block])
172
- send_req([args, work_block])
173
- true
174
- rescue ClosedQueueError, IOError
175
- false
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
- @req_counter.wait_until_less_than(@max_num * @snd_queue_max) if @snd_queue_max > 0
146
- @req_counter.push(true)
147
- @snd_queue.push([args, work_block])
148
- true
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: concurrent_worker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.6
4
+ version: 0.4.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - dddogdiamond