Sha256: 9da865b30c96f814222df1c94f4e2dc563d400f580c3e608c5b0d264c63fe853
Contents?: true
Size: 855 Bytes
Versions: 4
Compression:
Stored size: 855 Bytes
Contents
module Celluloid module Internals module CPUCounter class << self def cores @cores ||= count_cores end private def count_cores result = from_env || from_sysdev || from_sysctl Integer(result.to_s[/\d+/], 10) if result end def from_env result = ENV["NUMBER_OF_PROCESSORS"] result if result end def from_sysdev ::IO.read("/sys/devices/system/cpu/present").split("-").last.to_i + 1 rescue Errno::ENOENT result = Dir["/sys/devices/system/cpu/cpu*"].count { |n| n =~ /cpu\d+/ } result unless result.zero? end def from_sysctl result = `sysctl -n hw.ncpu` result if $CHILD_STATUS.success? rescue Errno::ENOENT end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems