concurrent_worker 0.4.1 → 0.4.3

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: 695c62e55f8cbedfffed63cee4fc4f6adfe8f975002406878af4b804ae051304
4
- data.tar.gz: 3cc2f1074a15fc9d3826d04752262efb251fcdd19183608b8b233737b8f76951
3
+ metadata.gz: e56634916dc036659f6d54c23222848245290ed9281b403268e0e1fa6c434ab4
4
+ data.tar.gz: ab979cc0dd7b75f00272f7cbd243a5fa6688d91556905731194ced74534ba16c
5
5
  SHA512:
6
- metadata.gz: 5b6921bc9aafd1f7a20888a084cb425e5c3e65a3caa60ff2ddb937aed6084129c5f4060ecc0870ac55843351ecad6133bbee036ff1805743513f3af705b9bf9a
7
- data.tar.gz: fea9f25a9715d7c19145c12736259f65e72dc942eae369d0125236ba25b96c2e68b7da66fbbb747b090360800d92cc2774a40befc99f013b82b485a7c291c38d
6
+ metadata.gz: c02c7b51f59108cf48db4e5d9eab8e5789c49015c15b3b0203b1fdd99d9cd02771ea6ec7ac83f171f08644b943267b325a05e0162afd03d417f8eb6c070ab356
7
+ data.tar.gz: f5eac16902da77e20410470520badd1da0b28bb6239fb64a2fad72622515c20971ead92a3b57ac12ad13f3dd8add2f50472a8735124e65af60daf93882eb5f54
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- concurrent_worker (0.4.1)
4
+ concurrent_worker (0.4.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,3 +1,3 @@
1
1
  module ConcurrentWorker
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.3"
3
3
  end
@@ -18,9 +18,6 @@ module ConcurrentWorker
18
18
  def queue_empty?
19
19
  !queue_closed? && @req_counter.size == 0
20
20
  end
21
- def queue_available?
22
- !queue_closed? && ( @snd_queue_max == 0 || @req_counter.size < @snd_queue_max )
23
- end
24
21
 
25
22
  def initialize(*args, **options, &work_block)
26
23
  @args = args
@@ -16,7 +16,7 @@ module ConcurrentWorker
16
16
  @m.synchronize do
17
17
  queued = []
18
18
  queued.push(super_pop) until empty?
19
- queued.sort_by{ |w| w.req_counter.size }.each{ |w| super_push(w) }
19
+ queued.sort_by{ |w| w.req_counter.size }.each{ |w| !w.queue_closed? && super_push(w) }
20
20
  end
21
21
  super_pop
22
22
  end
@@ -87,6 +87,23 @@ module ConcurrentWorker
87
87
  raise "block is nil" unless callback
88
88
  @finished_callbacks.push(callback)
89
89
  end
90
+
91
+ def worker_pool_com_setting(w)
92
+ w.add_callback do |*args|
93
+ @recv_queue.push([args])
94
+ @ready_queue.push(w)
95
+ end
96
+
97
+ w.add_retired_callback do
98
+ w.undone_requests.each do |req|
99
+ @snd_queue.push(req)
100
+ end
101
+ end
102
+
103
+ w.snd_queue_max.times do
104
+ @ready_queue.push(w)
105
+ end
106
+ end
90
107
 
91
108
 
92
109
  def deploy_worker
@@ -98,26 +115,14 @@ module ConcurrentWorker
98
115
  retired_callback_interrupt: :never
99
116
  }
100
117
  w = Worker.new(*@args, worker_options, &@work_block)
101
- w.add_callback do |*args|
102
- @recv_queue.push([args])
103
- @ready_queue.push(w)
104
- end
105
-
106
- w.add_retired_callback do
107
- w.undone_requests.each do
108
- |req|
109
- @snd_queue.push(req)
110
- end
111
- end
112
118
 
113
119
  @set_blocks.each do |symbol, block|
114
120
  w.set_block(symbol, &block)
115
121
  end
122
+
123
+ worker_pool_com_setting(w)
116
124
  w.run
117
125
 
118
- w.snd_queue_max.times do
119
- @ready_queue.push(w)
120
- end
121
126
  self.push(w)
122
127
  w
123
128
  end
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.1
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - dddogdiamond