diff --git a/lib/rscons/environment.rb b/lib/rscons/environment.rb index e7369ec..d2851b1 100644 --- a/lib/rscons/environment.rb +++ b/lib/rscons/environment.rb @@ -1,7 +1,6 @@ require "fileutils" require "set" require "shellwords" -require "thwait" module Rscons # The Environment class is the main programmatic interface to Rscons. It @@ -702,10 +701,7 @@ module Rscons !thread.alive? end else - if @threads.empty? - raise "No threads to wait for" - end - ThreadsWait.new(*@threads.keys).next_wait + Util.wait_for_thread(*@threads.keys) end end diff --git a/lib/rscons/util.rb b/lib/rscons/util.rb index 256547b..2958424 100644 --- a/lib/rscons/util.rb +++ b/lib/rscons/util.rb @@ -191,6 +191,32 @@ module Rscons deps end + # Wait for any of a number of threads to complete. + # + # @param threads [Array] + # Threads to wait for. + # + # @return [Thread] + # The Thread that completed. + 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 + private # Check if a directory contains a certain executable. diff --git a/spec/build_tests_spec.rb b/spec/build_tests_spec.rb index a8389e2..31656f4 100644 --- a/spec/build_tests_spec.rb +++ b/spec/build_tests_spec.rb @@ -143,7 +143,7 @@ EOF end end stdout, stderr, status = nil, nil, nil - Bundler.with_clean_env do + Bundler.with_unbundled_env do env = ENV.to_h path = ["#{@build_test_run_dir}/_bin", "#{env["PATH"]}"] if options[:path]