Module: Enumerable

Defined in:
lib/easysuite.rb

Overview

– Enumerable ++ Add method.

Instance Method Summary collapse

Instance Method Details

#peach(pool_size = 2) ⇒ Object

– peach ++ Parallel each method. Each block is run on worker threads.

pool_size

Maximum size of worker threads.(default: 2) If the value is not positive, there is no limit.



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/easysuite.rb', line 60

def peach(pool_size = 2)
  if block_given?
    pool = EasySuite::ThreadPool.new(pool_size)

    self.each do |args|
      pool.execute { yield(args) }
    end

    pool.shutdown
  else
    self.each
  end
end