forkoff 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/forkoff.gemspec +1 -1
- data/lib/forkoff.rb +5 -12
- metadata +2 -2
data/forkoff.gemspec
CHANGED
data/lib/forkoff.rb
CHANGED
@@ -2,17 +2,13 @@ require 'thread'
|
|
2
2
|
|
3
3
|
module Forkoff
|
4
4
|
def version
|
5
|
-
'1.1.
|
5
|
+
'1.1.1'
|
6
6
|
end
|
7
7
|
|
8
8
|
def done
|
9
9
|
@done ||= Object.new
|
10
10
|
end
|
11
11
|
|
12
|
-
def ready
|
13
|
-
@ready ||= Object.new
|
14
|
-
end
|
15
|
-
|
16
12
|
def default
|
17
13
|
@default ||= { 'processes' => 2 }
|
18
14
|
end
|
@@ -141,8 +137,7 @@ module Enumerable
|
|
141
137
|
options = { 'processes' => Integer(options) } unless Hash === options
|
142
138
|
n = Integer( options['processes'] || options[:processes] || Forkoff.default['processes'] )
|
143
139
|
strategy = options['strategy'] || options[:strategy] || 'pipe'
|
144
|
-
|
145
|
-
c2p = Queue.new
|
140
|
+
q = SizedQueue.new(n)
|
146
141
|
results = Array.new(n){ [] }
|
147
142
|
|
148
143
|
#
|
@@ -156,8 +151,7 @@ module Enumerable
|
|
156
151
|
Thread.current.abort_on_exception = true
|
157
152
|
|
158
153
|
loop do
|
159
|
-
|
160
|
-
value = p2c.pop
|
154
|
+
value = q.pop
|
161
155
|
break if value == Forkoff.done
|
162
156
|
args, index = value
|
163
157
|
|
@@ -187,11 +181,10 @@ module Enumerable
|
|
187
181
|
Thread.new do
|
188
182
|
Thread.current.abort_on_exception = true
|
189
183
|
each_with_index do |args, i|
|
190
|
-
|
191
|
-
p2c.push( [args, i] )
|
184
|
+
q.push( [args, i] )
|
192
185
|
end
|
193
186
|
n.times do |i|
|
194
|
-
|
187
|
+
q.push( Forkoff.done )
|
195
188
|
end
|
196
189
|
end
|
197
190
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: forkoff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ara T. Howard
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-12 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|