Sha256: 242589b3ec1d9f92b1ef530f368f5433c655a0ffa57b8b316ff6a199b16ca377

Contents?: true

Size: 444 Bytes

Versions: 1

Compression:

Stored size: 444 Bytes

Contents

require 'rbconfig'

module Celluloid
  module CPUCounter
    case RbConfig::CONFIG['host_os'][/^[A-Za-z]+/]
    when 'darwin'
      @cores = Integer(`sysctl hw.ncpu`[/\d+/])
    when 'linux'
      @cores = File.read("/proc/cpuinfo").scan(/(?:core id|processor)\s+: \d+/).uniq.size
    when 'mingw', 'mswin'
      @cores = Integer(`SET NUMBER_OF_PROCESSORS`[/\d+/])
    else
      @cores = nil
    end

    def self.cores; @cores; end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
celluloid-0.13.0.pre lib/celluloid/cpu_counter.rb