Module: DebDeploy::LazyEnumerable

Defined in:
lib/deb_deploy/util/collection_utils.rb

Instance Method Summary collapse

Instance Method Details

#each(&block) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/deb_deploy/util/collection_utils.rb', line 3

def each(&block)
  threads = []
  super do |item|
    threads << Thread.new { yield item }
  end
  threads.each(&:join)
end

#map(&block) ⇒ Object



11
12
13
14
15
# File 'lib/deb_deploy/util/collection_utils.rb', line 11

def map(&block)
  super do |item|
    Thread.new { Thread.current[:output] = block[item] }
  end.map(&:join).map { |thread| thread[:output] }
end