Class: Dynflow::Executors::Parallel::Pool::JobStorage

Inherits:
Object
  • Object
show all
Defined in:
lib/dynflow/executors/parallel/pool.rb

Instance Method Summary collapse

Constructor Details

#initializeJobStorage

Returns a new instance of JobStorage.



8
9
10
# File 'lib/dynflow/executors/parallel/pool.rb', line 8

def initialize
  @jobs = []
end

Instance Method Details

#add(work) ⇒ Object



12
13
14
# File 'lib/dynflow/executors/parallel/pool.rb', line 12

def add(work)
  @jobs << work
end

#empty?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/dynflow/executors/parallel/pool.rb', line 20

def empty?
  @jobs.empty?
end

#popObject



16
17
18
# File 'lib/dynflow/executors/parallel/pool.rb', line 16

def pop
  @jobs.shift
end

#queue_size(execution_plan_id = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/dynflow/executors/parallel/pool.rb', line 24

def queue_size(execution_plan_id = nil)
  if execution_plan_id
    @jobs.count do |item|
      item.respond_to?(:execution_plan_id) && item.execution_plan_id == execution_plan_id
    end
  else
    @jobs.size
  end
end