Module: ThreadsPerSlice
- Included in:
- ItemsForSalePopulator
- Defined in:
- lib/discogs/wishlist/mixins/threads_per_slice.rb
Instance Method Summary collapse
Instance Method Details
#threads_per_slice(enumerator, number_of_slices) ⇒ Object
2 3 4 5 6 7 8 9 10 11 |
# File 'lib/discogs/wishlist/mixins/threads_per_slice.rb', line 2 def threads_per_slice(enumerator, number_of_slices) mutex = Mutex.new threads = [] enumerator.each_slice(number_of_slices) do |slice| threads << Thread.new { yield slice, mutex } end threads.each(&:join) end |