num_workers.times.map do Thread.new do until (item = queue.pop) == :END do_something(item) end end end list.each { |item| queue << item } num_workers.times { queue << :END } threads.each(&:join)
nning 'patch' for libxml2 2.9.2... OK nning patch with /Library/Ruby/Gems/2.0.0/gems/nokogiri-1.6.6.2/ports/patches/libxml2/00 E-2014-3660-fix.patch... nning 'patch' for libxml2 2.9.2... OK nning 'configure' for libxml2 2.9.2... OK nning 'compile' for libxml2 2.9.2... ERROR, review '/Library/Ruby/Gems/2.0.0/gems/nokogi 6_64-apple-darwin14/ports/libxml2/2.9.2/compile.log' to see what happened. * extconf.rb failed *** uld not create Makefile due to some reason, probably lack of necessary braries and/or headers. Check the mkmf.log file for more details. You may ed configuration options. ovided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby --help --clean --use-system-libraries --enable-static --disable-static --with-zlib-dir
add(int, int)' end attr_reader :value def initialize(value) @value = value end def +(other) self.class.new(MyLib.add(value, other.value)) end protected :value end p MyNum.new(5) + MyNum.new(7) #=> #<MyNum:0x007f @value=12>