From 694642dfbde566ae529c9a7b4d2f27d70d71b0ff Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 13 Jun 2017 19:45:53 -0400 Subject: [PATCH] Allow overriding n_threads on a per-Environment level - close #34 --- lib/rscons/environment.rb | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/rscons/environment.rb b/lib/rscons/environment.rb index 2693710..9f39625 100644 --- a/lib/rscons/environment.rb +++ b/lib/rscons/environment.rb @@ -17,6 +17,11 @@ module Rscons # @return [String] The build root. attr_reader :build_root + # @return [Integer] + # The number of threads to use for this Environment. If nil (the + # default), the global Rscons.n_threads default value will be used. + attr_writer :n_threads + # Set the build root. # # @param build_root [String] The build root. @@ -331,7 +336,7 @@ module Rscons # If needed, do a blocking wait. if (@threaded_commands.size > 0) and - ((completed_tcs.empty? and job.nil?) or (@threaded_commands.size >= Rscons.n_threads)) + ((completed_tcs.empty? and job.nil?) or (@threaded_commands.size >= n_threads)) completed_tcs << wait_for_threaded_commands end @@ -828,6 +833,15 @@ module Rscons end end + # Get the number of threads to use for parallelized builds in this + # Environment. + # + # @return [Integer] + # Number of threads to use for parallelized builds in this Environment. + def n_threads + @n_threads || Rscons.n_threads + end + private # Add a build target.