class IOPromise::ExecutorPool::Batch

Public Class Methods

new(*) click to toggle source
Calls superclass method IOPromise::ExecutorPool::Base::new
# File lib/iopromise/executor_pool/batch.rb, line 6
def initialize(*)
  super
    
  @current_batch = []
end

Public Instance Methods

next_batch() click to toggle source
# 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
  # we don't include promises with a source set, because that
  # indicates that they depend on another promise now.
  @current_batch = @pending.select { |p| p.pending? && p.source.nil? }
end