Sha256: f8424ad4cb09934510636b27109eb1e094526fe12cb6ea1922c7ecb62a4df95b

Contents?: true

Size: 487 Bytes

Versions: 2

Compression:

Stored size: 487 Bytes

Contents

# frozen_string_literal: true

require 'concurrent/array'

module Capistrano
  module ASG
    module Rolling
      # Simple helper for running code in parallel.
      module Parallel
        module_function

        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
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
capistrano-asg-rolling-0.5.1 lib/capistrano/asg/rolling/parallel.rb
capistrano-asg-rolling-0.5.0 lib/capistrano/asg/rolling/parallel.rb