In Files

  • minitest/parallel_each.rb


Included Modules


Provides a parallel each that lets you enumerate using N threads. Use environment variable N to customize. Defaults to 2. Enumerable, so all the goodies come along (tho not all are wrapped yet to return another ParallelEach instance).



How many Threads to use for this parallel each.

Public Class Methods

new(list) click to toggle source

Create a new ParallelEach instance over list.

               # File minitest/parallel_each.rb, line 25
def initialize list
  @queue = # *sigh*... the Queue api sucks sooo much...

  list.each { |i| @queue << i }
  N.times { @queue << nil }

Public Instance Methods

count() click to toggle source
               # File minitest/parallel_each.rb, line 58
def count
  [@queue.size - N, 0].max
Also aliased as: size
each() click to toggle source

Starts N threads that yield each element to your block. Joins the threads at the end.

               # File minitest/parallel_each.rb, line 46
def each
  threads = { do
      Thread.current.abort_on_exception = true
      while job = @queue.pop
        yield job
size() click to toggle source
Alias for: count

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit

blog comments powered by Disqus