Class: Pwrake::IdleCores

Inherits:
Hash
  • Object
show all
Defined in:
lib/pwrake/master/idle_cores.rb

Instance Method Summary collapse

Instance Method Details

#decrease(k, n) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/pwrake/master/idle_cores.rb', line 12

def decrease(k,n)
  x = (self[k]||0) - n
  if x == 0
    delete(k)
  elsif x < 0
    raise "# of cores must be non-negative"
  else
    self[k] = x
  end
end

#increase(k, n) ⇒ Object



5
6
7
8
9
10
# File 'lib/pwrake/master/idle_cores.rb', line 5

def increase(k,n)
  if x = self[k]
    n += x
  end
  self[k] = n
end

#maxObject



23
24
25
26
27
# File 'lib/pwrake/master/idle_cores.rb', line 23

def max
  x = 0
  each{|k,v| x = v if v > x}
  x
end