module Pwrake::HrfQueue

HRF mixin module

Public Instance Methods

hrf_delete(t) click to toggle source
# File lib/pwrake/queue/queue_array.rb, line 122
def hrf_delete(t)
  @count[t.rank] -= t.use_cores(@nproc)
end
hrf_get(host_info, rank) click to toggle source
# File lib/pwrake/queue/queue_array.rb, line 86
def hrf_get(host_info, rank)
  (@count.size-1).downto(rank) do |r|
    c = @count[r]
    if c && c>0
      t = (c <= @nproc) ?
        pop_last_rank(r, host_info) :
        pop_super(host_info, rank)
      hrf_delete(t) if t
      return t
    end
  end
  Log.debug "#{self.class}#hrf_get: no item for rank=#{rank} @count=#{@count.inspect}"
  nil
end
hrf_init(nproc) click to toggle source
# File lib/pwrake/queue/queue_array.rb, line 75
def hrf_init(nproc)
  @nproc = nproc
  @count = []
end
hrf_push(t) click to toggle source
# File lib/pwrake/queue/queue_array.rb, line 80
def hrf_push(t)
  r = t.rank
  n = t.use_cores(@nproc)
  @count[r] = (@count[r] || 0) + n
end
pop_last_rank(r, host_info) click to toggle source
# File lib/pwrake/queue/queue_array.rb, line 101
def pop_last_rank(r, host_info)
  i_tried = nil
  size.times do |i|
    tw = q_at(i)
    if tw.rank == r && tw.acceptable_for(host_info)
      if tw.tried_host?(host_info)
        i_tried ||= i
      else
        Log.debug "#{self.class}: task=#{tw.name} i=#{i}/#{size} rank=#{tw.rank}"
        return q_delete_at(i)
      end
    end
  end
  if i_tried
    tw = q_at(i_tried)
    Log.debug "#{self.class}(retry): task=#{tw.name} i=#{i_tried}/#{size} rank=#{tw.rank}"
    return q_delete_at(i_tried)
  end
  nil
end