forkoff 1.1.0 → 1.1.1

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.
Files changed (3) hide show
  1. data/forkoff.gemspec +1 -1
  2. data/lib/forkoff.rb +5 -12
  3. metadata +2 -2
@@ -4,7 +4,7 @@
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "forkoff"
6
6
  spec.description = 'brain-dead simple parallel processing for ruby'
7
- spec.version = "1.1.0"
7
+ spec.version = "1.1.1"
8
8
  spec.platform = Gem::Platform::RUBY
9
9
  spec.summary = "forkoff"
10
10
 
@@ -2,17 +2,13 @@ require 'thread'
2
2
 
3
3
  module Forkoff
4
4
  def version
5
- '1.1.0'
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
- p2c = Queue.new
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
- c2p.push( Forkoff.ready )
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
- ready = c2p.pop
191
- p2c.push( [args, i] )
184
+ q.push( [args, i] )
192
185
  end
193
186
  n.times do |i|
194
- p2c.push( Forkoff.done )
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.0
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-11 00:00:00 -06:00
12
+ date: 2009-10-12 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies: []
15
15