Module: Enumerable
- Defined in:
- lib/picolena/templates/lib/core_exts.rb
Instance Method Summary collapse
-
#each_with_thread(&block) ⇒ Object
Similar to Enumerable#each, but creates a new thread for each element.
Instance Method Details
#each_with_thread(&block) ⇒ Object
Similar to Enumerable#each, but creates a new thread for each element. Used for the indexer to make it multi-threaded. It ensures that threads are joined together before returning.
21 22 23 24 25 26 27 28 |
# File 'lib/picolena/templates/lib/core_exts.rb', line 21 def each_with_thread(&block) tds=self.collect{|elem| Thread.new(elem) {|elem| block.call(elem) } } tds.each{|aThread| aThread.join} end |