Class: Pwrake::HostInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/pwrake/option/host_map.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, id, ncore, weight, group = nil) ⇒ HostInfo

Returns a new instance of HostInfo.



5
6
7
8
9
10
11
# File 'lib/pwrake/option/host_map.rb', line 5

def initialize(name,id,ncore,weight,group=nil)
  @name = name
  @ncore = ncore
  @weight = weight || 1.0
  @group = group || 0
  @id = id
end

Instance Attribute Details

#groupObject (readonly)

Returns the value of attribute group.



13
14
15
# File 'lib/pwrake/option/host_map.rb', line 13

def group
  @group
end

#idObject (readonly)

Returns the value of attribute id.



13
14
15
# File 'lib/pwrake/option/host_map.rb', line 13

def id
  @id
end

#idle_coresObject

Returns the value of attribute idle_cores.



14
15
16
# File 'lib/pwrake/option/host_map.rb', line 14

def idle_cores
  @idle_cores
end

#nameObject (readonly)

Returns the value of attribute name.



13
14
15
# File 'lib/pwrake/option/host_map.rb', line 13

def name
  @name
end

#ncoreObject (readonly)

Returns the value of attribute ncore.



13
14
15
# File 'lib/pwrake/option/host_map.rb', line 13

def ncore
  @ncore
end

#steal_flagObject (readonly)

Returns the value of attribute steal_flag.



13
14
15
# File 'lib/pwrake/option/host_map.rb', line 13

def steal_flag
  @steal_flag
end

#weightObject (readonly)

Returns the value of attribute weight.



13
14
15
# File 'lib/pwrake/option/host_map.rb', line 13

def weight
  @weight
end

Instance Method Details

#decrease(n) ⇒ Object



24
25
26
27
28
29
# File 'lib/pwrake/option/host_map.rb', line 24

def decrease(n)
  @idle_cores -= n
  if @idle_cores < 0
    raise RuntimeError,"# of cores must be non-negative"
  end
end

#increase(n) ⇒ Object



20
21
22
# File 'lib/pwrake/option/host_map.rb', line 20

def increase(n)
  @idle_cores += n
end

#set_ncore(n) ⇒ Object



16
17
18
# File 'lib/pwrake/option/host_map.rb', line 16

def set_ncore(n)
  @ncore = @idle_cores = n
end

#steal_phaseObject



31
32
33
34
35
36
# File 'lib/pwrake/option/host_map.rb', line 31

def steal_phase
  @steal_flag = true
  t = yield(self)
  @steal_flag = false
  t
end