Module: GemsBond::Helpers::ConcurrencyHelper
Overview
Concurrency helper
Instance Method Summary collapse
-
#each_concurrently(items) {|item| ... } ⇒ void
Run each item concurrently.
Instance Method Details
#each_concurrently(items) {|item| ... } ⇒ void
This method returns an undefined value.
Run each item concurrently
15 16 17 18 19 20 21 |
# File 'lib/gems_bond/helpers/concurrency_helper.rb', line 15 def each_concurrently(items) threads = [] items.each do |item| threads << Thread.new { block_given? ? yield(item) : item } end threads.each(&:join) end |