Class: Pwrake::NonLocalityQueue
- Inherits:
-
Object
- Object
- Pwrake::NonLocalityQueue
- Defined in:
- lib/pwrake/queue/non_locality_queue.rb
Instance Attribute Summary collapse
-
#turns ⇒ Object
readonly
Returns the value of attribute turns.
Instance Method Summary collapse
- #clear ⇒ Object
- #deq_impl(host_info, turn) ⇒ Object
- #deq_start ⇒ Object
- #drop_host(host_info) ⇒ Object
- #empty? ⇒ Boolean
- #enq_impl(tw) ⇒ Object
-
#initialize(hostinfo_by_id, array_class, median_core, group_map = nil) ⇒ NonLocalityQueue
constructor
A new instance of NonLocalityQueue.
- #inspect_q ⇒ Object
- #size ⇒ Object
- #turn_empty?(turn) ⇒ Boolean
Constructor Details
#initialize(hostinfo_by_id, array_class, median_core, group_map = nil) ⇒ NonLocalityQueue
Returns a new instance of NonLocalityQueue.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/pwrake/queue/non_locality_queue.rb', line 9 def initialize(hostinfo_by_id, array_class, median_core, group_map=nil) @hostinfo_by_id = hostinfo_by_id @array_class = array_class @median_core = median_core @disable_rank = Rake.application.['DISABLE_RANK_PRIORITY'] Log.debug "#{self.class}: @disable_rank=#{@disable_rank.inspect}" @q_input = @array_class.new(@median_core) @q_no_input = FifoQueueArray.new(@median_core) @turns = [0] end |
Instance Attribute Details
#turns ⇒ Object (readonly)
Returns the value of attribute turns.
20 21 22 |
# File 'lib/pwrake/queue/non_locality_queue.rb', line 20 def turns @turns end |
Instance Method Details
#clear ⇒ Object
53 54 55 56 |
# File 'lib/pwrake/queue/non_locality_queue.rb', line 53 def clear @q_input.clear @q_no_input.clear end |
#deq_impl(host_info, turn) ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/pwrake/queue/non_locality_queue.rb', line 38 def deq_impl(host_info, turn) case turn when 0 @q_input.shift(host_info,@rank) || @q_no_input.shift(host_info,@rank) else raise "invalid turn: #{turn}" end end |
#deq_start ⇒ Object
34 35 36 |
# File 'lib/pwrake/queue/non_locality_queue.rb', line 34 def deq_start @rank = @disable_rank ? 0 : @q_input.find_rank(@median_core) end |
#drop_host(host_info) ⇒ Object
68 69 |
# File 'lib/pwrake/queue/non_locality_queue.rb', line 68 def drop_host(host_info) end |
#empty? ⇒ Boolean
58 59 60 61 |
# File 'lib/pwrake/queue/non_locality_queue.rb', line 58 def empty? @q_input.empty? && @q_no_input.empty? end |
#enq_impl(tw) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/pwrake/queue/non_locality_queue.rb', line 22 def enq_impl(tw) if tw.has_input_file? @q_input.push(tw) else @q_no_input.push(tw) end end |
#inspect_q ⇒ Object
63 64 65 66 |
# File 'lib/pwrake/queue/non_locality_queue.rb', line 63 def inspect_q TaskQueue._qstr("input", @q_input) + TaskQueue._qstr("no_input",@q_no_input) end |
#size ⇒ Object
48 49 50 51 |
# File 'lib/pwrake/queue/non_locality_queue.rb', line 48 def size @q_input.size + @q_no_input.size end |
#turn_empty?(turn) ⇒ Boolean
30 31 32 |
# File 'lib/pwrake/queue/non_locality_queue.rb', line 30 def turn_empty?(turn) empty? end |