Sha256: 4fe3a7126687ae4562cb692804ee09df9f06a77e34b13131960bf60ac4524191

Contents?: true

Size: 512 Bytes

Versions: 6

Compression:

Stored size: 512 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.each do |w|
            threads << Thread.new do
              result << yield(w)
            end
          end

          threads.each(&:join)

          result
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
capistrano-asg-rolling-0.4.1 lib/capistrano/asg/rolling/parallel.rb
capistrano-asg-rolling-0.4.0 lib/capistrano/asg/rolling/parallel.rb
capistrano-asg-rolling-0.3.0 lib/capistrano/asg/rolling/parallel.rb
capistrano-asg-rolling-0.2.1 lib/capistrano/asg/rolling/parallel.rb
capistrano-asg-rolling-0.2.0 lib/capistrano/asg/rolling/parallel.rb
capistrano-asg-rolling-0.1.0 lib/capistrano/asg/rolling/parallel.rb