Class: IOPromise::ExecutorPool::Batch
- Defined in:
- lib/iopromise/executor_pool/batch.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize ⇒ Batch
constructor
A new instance of Batch.
- #next_batch ⇒ Object
Methods inherited from Base
#begin_executing, #execute_continue, for, #promise_cancelled, #promise_fulfilled, #promise_rejected, #register, #sync
Constructor Details
#initialize ⇒ Batch
Returns a new instance of Batch.
6 7 8 9 10 |
# File 'lib/iopromise/executor_pool/batch.rb', line 6 def initialize(*) super @current_batch = [] end |
Instance Method Details
#next_batch ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# 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 |