Class: Gilmour::Composers::Parallel
- Defined in:
- lib/gilmour/composers.rb
Instance Attribute Summary
Attributes inherited from Pipeline
Instance Method Summary collapse
-
#execute(data = nil, &blk) ⇒ Object
Execute the batch pipeline.
-
#initialize(backend, spec) ⇒ Parallel
constructor
:nodoc:.
Methods inherited from Pipeline
Constructor Details
#initialize(backend, spec) ⇒ Parallel
:nodoc:
199 200 201 |
# File 'lib/gilmour/composers.rb', line 199 def initialize(backend, spec) #:nodoc: super(backend, spec) end |
Instance Method Details
#execute(data = nil, &blk) ⇒ Object
Execute the batch pipeline. This pipeline ignores all errors step is passed to block. See the documentation of the #batch method for more details
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/gilmour/composers.rb', line 206 def execute(data=nil, &blk) results = [] blk.call(nil, nil) if pipeline.empty? waiters = [] pipeline.each do |p| waiter = Gilmour::Waiter.new waiters << waiter p.execute do |d, c| results << {data: d, code: c} waiter.signal end end waiters.each(&:wait) code = results.map { |r| r[:code] }.max blk.call(results, code) end |