Sha256: 32af35d17a7fffcb0941d9875e5ec81611956f810520dfdbbb671203b785c7ad

Contents?: true

Size: 346 Bytes

Versions: 5

Compression:

Stored size: 346 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\s+: \d+/).uniq.size
    else
      @cores = nil
    end

    def self.cores; @cores; end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
celluloid-0.11.1 lib/celluloid/cpu_counter.rb
celluloid-0.11.0 lib/celluloid/cpu_counter.rb
kulesa-celluloid-0.10.2 lib/celluloid/cpu_counter.rb
celluloid-0.10.0 lib/celluloid/cpu_counter.rb
celluloid-0.9.1 lib/celluloid/cpu_counter.rb