Permalink
Browse files

Use suggested thread count when no -j is given.

  • Loading branch information...
1 parent 95514fa commit ecdcbc98fbc3ce9da166ba1e0f4bfe96db8a711c @jimweirich committed Jun 20, 2013
Showing with 6 additions and 3 deletions.
  1. +1 −1 lib/rake/application.rb
  2. +2 −2 lib/rake/rake_module.rb
  3. +3 −0 test/test_rake_application_options.rb
View
@@ -138,7 +138,7 @@ def options
# Return the thread pool used for multithreaded processing.
def thread_pool # :nodoc:
- @thread_pool ||= ThreadPool.new(options.thread_pool_size || FIXNUM_MAX)
+ @thread_pool ||= ThreadPool.new(options.thread_pool_size || Rake.suggested_thread_count-1)
end
# private ----------------------------------------------------------------
View
@@ -16,8 +16,8 @@ def application=(app)
end
def suggested_thread_count
- cpus = Rake::CpuCounter.count || 2
- cpus + 4
+ @cpu_count ||= Rake::CpuCounter.count
+ @cpu_count + 4
end
# Return the original directory where the Rake application was started.
@@ -111,6 +111,9 @@ def test_help
end
def test_jobs
+ flags([]) do |opts|
+ assert_nil opts.thread_pool_size
+ end
flags(['--jobs', '0'], ['-j', '0']) do |opts|
assert_equal 0, opts.thread_pool_size
end

0 comments on commit ecdcbc9

Please sign in to comment.