Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/concurrent/utility/processor_counter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'etc'
require 'rbconfig'
require 'concurrent/delay'

Expand All @@ -22,6 +23,8 @@ def initialize
# occasionally poll this property." Subsequently the result will NOT be
# memoized under JRuby.
#
# Ruby's Etc.nprocessors will be used if available (MRI 2.2+).
#
# On Windows the Win32 API will be queried for the
# `NumberOfLogicalProcessors from Win32_Processor`. This will return the
# total number "logical processors for the current instance of the
Expand Down Expand Up @@ -76,6 +79,8 @@ def physical_processor_count
def compute_processor_count
if Concurrent.on_jruby?
java.lang.Runtime.getRuntime.availableProcessors
elsif Etc.respond_to?(:nprocessors) && (nprocessor = Etc.nprocessors rescue nil)
nprocessor
else
os_name = RbConfig::CONFIG["target_os"]
if os_name =~ /mingw|mswin/
Expand Down