File tree Expand file tree Collapse file tree 1 file changed +5
-0
lines changed
Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Original file line number Diff line number Diff line change 1+ require 'etc'
12require 'rbconfig'
23require 'concurrent/delay'
34
@@ -22,6 +23,8 @@ def initialize
2223 # occasionally poll this property." Subsequently the result will NOT be
2324 # memoized under JRuby.
2425 #
26+ # Ruby's Etc.nprocessors will be used if available (MRI 2.2+).
27+ #
2528 # On Windows the Win32 API will be queried for the
2629 # `NumberOfLogicalProcessors from Win32_Processor`. This will return the
2730 # total number "logical processors for the current instance of the
@@ -76,6 +79,8 @@ def physical_processor_count
7679 def compute_processor_count
7780 if Concurrent . on_jruby?
7881 java . lang . Runtime . getRuntime . availableProcessors
82+ elsif Etc . respond_to? ( :nprocessors ) && ( nprocessor = Etc . nprocessors rescue nil )
83+ nprocessor
7984 else
8085 os_name = RbConfig ::CONFIG [ "target_os" ]
8186 if os_name =~ /mingw|mswin/
You can’t perform that action at this time.
0 commit comments