Module: Capistrano::ASG::Rolling::Parallel

Defined in:
lib/capistrano/asg/rolling/parallel.rb

Overview

Simple helper for running code in parallel.

Class Method Summary collapse

Class Method Details

.run(work) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/capistrano/asg/rolling/parallel.rb', line 12

def run(work)
  result = Concurrent::Array.new

  threads = work.map do |w|
    Thread.new do
      result << yield(w)
    end
  end

  threads.each(&:join)

  result
end