Module: Enumerable

Included in:
InThreads::Filler::Extractor
Defined in:
lib/in_threads/enumerable.rb

Instance Method Summary collapse

Instance Method Details

#in_threads(thread_count = 10, &block) ⇒ Object

Run enumerable method blocks in threads

urls.in_threads.map do |url|
  url.fetch
end

Specify number of threads to use:

files.in_threads(4).all? do |file|
  file.valid?
end

Passing block runs it against each

urls.in_threads.each{  }

is same as

urls.in_threads{  }


23
24
25
# File 'lib/in_threads/enumerable.rb', line 23

def in_threads(thread_count = 10, &block)
  InThreads.new(self, thread_count, &block)
end