Module: Farce::System

Defined in:
lib/farce/system.rb

Overview

Information about the system running Farce.

Class Method Summary collapse

Class Method Details

.cpu_count(type = nil) ⇒ Integer?

Number of logical CPUs, optionally limited to a CPU type. Returns nil when the platform cannot report the requested CPU type. Safe to call from any Ractor.

Parameters:

  • type (nil, Symbol) (defaults to: nil) —

    nil for all CPUs, :performance, or :efficiency

Returns:

  • (Integer, nil)

Raises:

  • (ArgumentError) —

    if the CPU type is invalid



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/farce/system.rb', line 24

def self.cpu_count(type = nil)
  case type
  when nil
    if defined?(Internal::Darwin) && Internal::Darwin.respond_to?(:cpu_count)
      Internal::Darwin.cpu_count
    else
      Etc.nprocessors
    end
  when :performance, :efficiency
    method = :"#{type}_cpu_count"
    Internal::Darwin.public_send(method) if defined?(Internal::Darwin) && Internal::Darwin.respond_to?(method)
  else
    raise ArgumentError, "invalid CPU type: #{type.inspect}"
  end
end

.windows? ⇒ Boolean

Whether the current operating system is Windows. Safe to call from any Ractor.

Returns:

  • (Boolean)


16
# File 'lib/farce/system.rb', line 16

def self.windows? = WINDOWS