Sha256: b3da07b779eb5354a17a84d5350ee607d05b6d77c08be0cc2d0028844d8b6e9a

Contents?: true

Size: 318 Bytes

Versions: 42

Compression:

Stored size: 318 Bytes

Contents

# frozen_string_literal: true

require 'etc'

module Switchman
  class Environment
    def self.cpu_count(nproc_bin = 'nproc')
      return Etc.nprocessors if Etc.respond_to?(:nprocessors)

      `#{nproc_bin}`.to_i
    rescue Errno::ENOENT
      # an environment where nproc` isnt available
      0
    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
switchman-3.0.21 lib/switchman/environment.rb
switchman-3.0.20 lib/switchman/environment.rb
switchman-3.0.19 lib/switchman/environment.rb
switchman-3.0.18 lib/switchman/environment.rb
switchman-3.0.17 lib/switchman/environment.rb
switchman-3.0.16 lib/switchman/environment.rb
switchman-3.0.15 lib/switchman/environment.rb
switchman-3.0.14 lib/switchman/environment.rb
switchman-3.0.13 lib/switchman/environment.rb
switchman-3.0.12 lib/switchman/environment.rb
switchman-3.0.11 lib/switchman/environment.rb
switchman-3.0.10 lib/switchman/environment.rb
switchman-3.0.9 lib/switchman/environment.rb
switchman-3.0.8 lib/switchman/environment.rb
switchman-3.0.7 lib/switchman/environment.rb
switchman-3.0.6 lib/switchman/environment.rb
switchman-3.0.5 lib/switchman/environment.rb
switchman-3.0.4 lib/switchman/environment.rb
switchman-3.0.3 lib/switchman/environment.rb
switchman-3.0.2 lib/switchman/environment.rb