Module: SupplyDrop::AsyncEnumerable

Defined in:
lib/supply_drop/async_enumerable.rb

Instance Method Summary collapse

Instance Method Details

#each(&block) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/supply_drop/async_enumerable.rb', line 3

def each(&block)
  pool = SupplyDrop::ThreadPool.new(SupplyDrop::Util.thread_pool_size)
  super do |item|
    pool.schedule(item, &block)
  end
  pool.shutdown
end

#map(&block) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/supply_drop/async_enumerable.rb', line 11

def map(&block)
  pool = SupplyDrop::ThreadPool.new(SupplyDrop::Util.thread_pool_size)
  super do |item|
    pool.schedule(item, &block)
  end
  pool.shutdown
end