Method: Bake::Multithread::Jobs#initialize
- Defined in:
- lib/multithread/job.rb
#initialize(jobs, &block) ⇒ Jobs
Returns a new instance of Jobs.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/multithread/job.rb', line 22 def initialize(jobs, &block) nr_of_threads = [Bake..threads, jobs.length].min @jobs = jobs @threads = [] nr_of_threads.times do @threads << ::Thread.new(Thread.current[:stdout]) do |outStr| Thread.current[:stdout] = outStr begin Jobs.incThread() block.call(self) ensure Jobs.decThread() end end end end |