Module: Enumerable
- Defined in:
- lib/easysuite.rb
Overview
– Enumerable ++ Add method.
Instance Method Summary collapse
-
#peach(pool_size = 2) ⇒ Object
– peach ++ Parallel each method.
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 73 74 75 |
# File 'lib/easysuite.rb', line 60 def peach(pool_size = 2) if block_given? max_pools = 32 pool_size = max_pools if (pool_size <= 0) pool_size = [pool_size, max_pools].min pool = EasySuite::ThreadPool.new(pool_size) self.each do |args| pool.execute { yield(args) } end pool.shutdown else self.each end end |