Class: Dynflow::Executors::Parallel::Pool::JobStorage
- Inherits:
-
Object
- Object
- Dynflow::Executors::Parallel::Pool::JobStorage
- Defined in:
- lib/dynflow/executors/parallel/pool.rb
Instance Method Summary collapse
- #add(work) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize ⇒ JobStorage
constructor
A new instance of JobStorage.
- #pop ⇒ Object
- #queue_size(execution_plan_id = nil) ⇒ Object
Constructor Details
#initialize ⇒ JobStorage
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
20 21 22 |
# File 'lib/dynflow/executors/parallel/pool.rb', line 20 def empty? @jobs.empty? end |
#pop ⇒ Object
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 |