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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/concurrent_worker/version.rb +1 -1
- data/lib/concurrent_worker/worker.rb +0 -3
- data/lib/concurrent_worker/workerpool.rb +20 -15
- 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: e56634916dc036659f6d54c23222848245290ed9281b403268e0e1fa6c434ab4
|
4
|
+
data.tar.gz: ab979cc0dd7b75f00272f7cbd243a5fa6688d91556905731194ced74534ba16c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c02c7b51f59108cf48db4e5d9eab8e5789c49015c15b3b0203b1fdd99d9cd02771ea6ec7ac83f171f08644b943267b325a05e0162afd03d417f8eb6c070ab356
|
7
|
+
data.tar.gz: f5eac16902da77e20410470520badd1da0b28bb6239fb64a2fad72622515c20971ead92a3b57ac12ad13f3dd8add2f50472a8735124e65af60daf93882eb5f54
|
data/Gemfile.lock
CHANGED
@@ -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
|