Sha256: a8345443e0708d79aedc3fd84214fa55b8a16ac33e243098f498eb48e8921a68

Contents?: true

Size: 618 Bytes

Versions: 42

Compression:

Stored size: 618 Bytes

Contents

module S3Website
  class Parallelism
    def self.each_in_parallel_or_sequentially(items, config, &operation)
      if ENV['disable_parallel_processing']
        items.each do |item|
          operation.call item
        end
      else
        slice_size = config['concurrency_level'] || DEFAULT_CONCURRENCY_LEVEL
        items.each_slice(slice_size) { |items|
          threads = items.map do |item|
            Thread.new(item) { |item|
              operation.call item
            }
          end
          threads.each(&:join)
        }
      end
    end

    private

    DEFAULT_CONCURRENCY_LEVEL = 3
  end
end

Version data entries

42 entries across 42 versions & 2 rubygems

Version Path
s3_website-1.8.2 lib/s3_website/parallelism.rb
s3_website-1.8.1 lib/s3_website/parallelism.rb
s3_website-1.8.0 lib/s3_website/parallelism.rb
s3_website_monadic-0.0.15 lib/s3_website/parallelism.rb
s3_website_monadic-0.0.14 lib/s3_website/parallelism.rb
s3_website_monadic-0.0.13 lib/s3_website/parallelism.rb
s3_website_monadic-0.0.12 lib/s3_website/parallelism.rb
s3_website_monadic-0.0.11 lib/s3_website/parallelism.rb
s3_website_monadic-0.0.9 lib/s3_website/parallelism.rb
s3_website_monadic-0.0.8 lib/s3_website/parallelism.rb
s3_website_monadic-0.0.7 lib/s3_website/parallelism.rb
s3_website_monadic-0.0.6 lib/s3_website/parallelism.rb
s3_website_monadic-0.0.5 lib/s3_website/parallelism.rb
s3_website-1.7.6 lib/s3_website/parallelism.rb
s3_website_monadic-0.0.4 lib/s3_website/parallelism.rb
s3_website_monadic-0.0.3 lib/s3_website/parallelism.rb
s3_website-1.7.5 lib/s3_website/parallelism.rb
s3_website_monadic-0.0.2 lib/s3_website/parallelism.rb
s3_website_monadic-0.0.1 lib/s3_website/parallelism.rb
s3_website-1.7.4 lib/s3_website/parallelism.rb