Class: Cuboid::System
- Includes:
- Singleton
- Defined in:
- lib/cuboid/system.rb,
lib/cuboid/system/slots.rb,
lib/cuboid/system/platforms.rb,
lib/cuboid/system/platforms/osx.rb,
lib/cuboid/system/platforms/linux.rb,
lib/cuboid/system/platforms/windows.rb,
lib/cuboid/system/platforms/mixins/unix.rb
Defined Under Namespace
Modules: Platforms Classes: Slots
Instance Attribute Summary collapse
- #platforms ⇒ Array<Platforms::Base> readonly
- #slots ⇒ Slots readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#cpu_count ⇒ Integer
Amount of CPU cores.
-
#disk_directory ⇒ String Location for temporary file storage.
String Location for temporary file storage.
-
#disk_space_for_process(pid) ⇒ Integer
Amount of disk space in bytes used by the given PID.
-
#disk_space_free ⇒ Integer
Amount of free disk space in bytes.
-
#initialize ⇒ System
constructor
A new instance of System.
- #max_utilization? ⇒ Bool
-
#memory_for_process_group(pgid) ⇒ Integer
Amount of RAM in bytes used by the given GPID.
-
#memory_free ⇒ Integer
Amount of free RAM in bytes.
- #platform ⇒ Platforms::Base
- #register_platform(platform) ⇒ Object
- #reset ⇒ Object
-
#utilization ⇒ Float
System utilization based on slots.
Constructor Details
Instance Attribute Details
#platforms ⇒ Array<Platforms::Base> (readonly)
9 10 11 |
# File 'lib/cuboid/system.rb', line 9 def platforms @platforms end |
Class Method Details
.method_missing(sym, *args, &block) ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/cuboid/system.rb', line 103 def method_missing( sym, *args, &block ) if instance.respond_to?( sym ) instance.send( sym, *args, &block ) else super( sym, *args, &block ) end end |
.respond_to?(*args) ⇒ Boolean
111 112 113 |
# File 'lib/cuboid/system.rb', line 111 def respond_to?( *args ) super || instance.respond_to?( *args ) end |
Instance Method Details
#cpu_count ⇒ Integer
Returns Amount of CPU cores.
74 75 76 |
# File 'lib/cuboid/system.rb', line 74 def cpu_count @cpu_count ||= platform.cpu_count end |
#disk_directory ⇒ String Location for temporary file storage.
Returns String Location for temporary file storage.
59 60 61 |
# File 'lib/cuboid/system.rb', line 59 def disk_directory platform.disk_directory end |
#disk_space_for_process(pid) ⇒ Integer
Returns Amount of disk space in bytes used by the given PID.
68 69 70 |
# File 'lib/cuboid/system.rb', line 68 def disk_space_for_process( pid ) platform.disk_space_for_process( pid ) end |
#disk_space_free ⇒ Integer
Returns Amount of free disk space in bytes.
53 54 55 |
# File 'lib/cuboid/system.rb', line 53 def disk_space_free platform.disk_space_free end |
#max_utilization? ⇒ Bool
32 33 34 |
# File 'lib/cuboid/system.rb', line 32 def max_utilization? utilization == 1 end |
#memory_for_process_group(pgid) ⇒ Integer
Returns Amount of RAM in bytes used by the given GPID.
47 48 49 |
# File 'lib/cuboid/system.rb', line 47 def memory_for_process_group( pgid ) platform.memory_for_process_group( pgid ) end |
#memory_free ⇒ Integer
Returns Amount of free RAM in bytes.
38 39 40 |
# File 'lib/cuboid/system.rb', line 38 def memory_free platform.memory_free end |
#platform ⇒ Platforms::Base
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/cuboid/system.rb', line 79 def platform return @platform if @platform platforms.each do |klass| next if !klass.current? return @platform = klass.new end raise "Unsupported platform: #{RUBY_PLATFORM}" end |
#register_platform(platform) ⇒ Object
92 93 94 |
# File 'lib/cuboid/system.rb', line 92 def register_platform( platform ) platforms << platform end |
#reset ⇒ Object
97 98 99 100 |
# File 'lib/cuboid/system.rb', line 97 def reset @cpu_count = nil @platform = nil end |