Module: Rscons::Util
- Defined in:
- lib/rscons/util.rb
Overview
A collection of stand-alone utility methods.
Class Method Summary collapse
-
.wait_for_thread(*threads) ⇒ Thread
Wait for any of a number of threads to complete.
Class Method Details
.wait_for_thread(*threads) ⇒ Thread
Wait for any of a number of threads to complete.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rscons/util.rb', line 13 def wait_for_thread(*threads) if threads.empty? raise "No threads to wait for" end queue = Queue.new threads.each do |thread| # Create a wait thread for each thread we're waiting for. Thread.new do begin thread.join ensure queue.push(thread) end end end # Wait for any thread to complete. queue.pop end |