Module: ActiveGenie::FiberByBatch
- Defined in:
- lib/active_genie/utils/fiber_by_batch.rb
Class Method Summary collapse
Class Method Details
.call(items, config:, &block) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/active_genie/utils/fiber_by_batch.rb', line 9 def call(items, config:, &block) items.each_slice(config.llm.max_fibers).to_a.each do |batch| Async do |task| tasks = batch.map do |item| task.async { block.call(item) } end tasks.each(&:wait) end.wait end end |