Class: S3Website::Parallelism
- Inherits:
-
Object
- Object
- S3Website::Parallelism
- Defined in:
- lib/s3_website/parallelism.rb
Class Method Summary collapse
Class Method Details
.each_in_parallel_or_sequentially(items, &operation) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/s3_website/parallelism.rb', line 3 def self.each_in_parallel_or_sequentially(items, &operation) if ENV['disable_parallel_processing'] items.each do |item| operation.call item end else threads = items.map do |item| Thread.new(item) { |item| operation.call item } end threads.each { |thread| thread.join } end end |