Class: IOPromise::ExecutorPool::Batch

Inherits:
Base
  • Object
show all
Defined in:
lib/iopromise/executor_pool/batch.rb

Instance Method Summary collapse

Methods inherited from Base

#begin_executing, #complete, #execute_continue, for, #register, #sync

Constructor Details

#initialize(connection_pool) ⇒ Batch



6
7
8
9
10
# File 'lib/iopromise/executor_pool/batch.rb', line 6

def initialize(connection_pool)
  super(connection_pool)
    
  @current_batch = []
end

Instance Method Details

#next_batchObject



12
13
14
15
16
17
18
19
20
# File 'lib/iopromise/executor_pool/batch.rb', line 12

def next_batch
  # ensure that all current items are fully completed
  @current_batch.each do |promise|
    promise.wait
  end
  
  # every pending operation becomes part of the current batch
  @current_batch = @pending.dup
end