class Concurrent::Utility::ProcessorCounter
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/concurrent-ruby/concurrent/utility/processor_counter.rbs class Concurrent::Utility::ProcessorCounter def compute_physical_processor_count: () -> Integer def physical_processor_count: () -> Integer end
@!visibility private
def compute_physical_processor_count
Experimental RBS support (using type sampling data from the type_fusion
project).
def compute_physical_processor_count: () -> Integer
This signature was generated using 2 samples from 1 application.
def compute_physical_processor_count ppc = case RbConfig::CONFIG["target_os"] when /darwin\d\d/ IO.popen("/usr/sbin/sysctl -n hw.physicalcpu", &:read).to_i when /linux/ cores = {} # unique physical ID / core ID combinations phy = 0 IO.read("/proc/cpuinfo").scan(/^physical id.*|^core id.*/) do |ln| if ln.start_with?("physical") phy = ln[/\d+/] elsif ln.start_with?("core") cid = phy + ":" + ln[/\d+/] cores[cid] = true if not cores[cid] end end cores.count when /mswin|mingw/ require 'win32ole' result_set = WIN32OLE.connect("winmgmts://").ExecQuery( "select NumberOfCores from Win32_Processor") result_set.to_enum.collect(&:NumberOfCores).reduce(:+) else processor_count end # fall back to logical count if physical info is invalid ppc > 0 ? ppc : processor_count rescue return 1 end
def compute_processor_count
def compute_processor_count if Concurrent.on_jruby? java.lang.Runtime.getRuntime.availableProcessors else Etc.nprocessors end end
def initialize
def initialize @processor_count = Delay.new { compute_processor_count } @physical_processor_count = Delay.new { compute_physical_processor_count } end
def physical_processor_count
Experimental RBS support (using type sampling data from the type_fusion
project).
def physical_processor_count: () -> Integer
This signature was generated using 3 samples from 1 application.
def physical_processor_count @physical_processor_count.value end
def processor_count
def processor_count @processor_count.value end