Class: Pwrake::LifoQueueArray

Inherits:
Array
  • Object
show all
Defined in:
lib/pwrake/queue/queue_array.rb

Instance Method Summary collapse

Constructor Details

#initialize(n_cores = nil) ⇒ LifoQueueArray

Returns a new instance of LifoQueueArray.



65
66
67
# File 'lib/pwrake/queue/queue_array.rb', line 65

def initialize(n_cores=nil)
  super()
end

Instance Method Details

#shift(host_info = nil) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/pwrake/queue/queue_array.rb', line 69

def shift(host_info=nil)
  return super() unless host_info
  i_found = nil
  (size-1).downto(0) do |i|
    tw = at(i)
    if tw.acceptable_for(host_info)
      if tw.untried_host?(host_info)
        return delete_at(i)
      else
        i_found ||= i
      end
    end
  end
  (i_found) ? delete_at(i_found) : nil
end