Module: Async

Defined in:
lib/async/tools/version.rb,
lib/async/tools.rb

Overview

rubocop:disable Style/ClassAndModuleChildren

Defined Under Namespace

Modules: Logger, Tools Classes: App, Bus, Cache, Channel, Q, ResultNotification, Throttler, Timer, WorkerPool

Class Method Summary collapse

Class Method Details

.map(collection, concurrency: nil, parent: Async::Task.current) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/async/tools.rb', line 23

def self.map(collection, concurrency: nil, parent: Async::Task.current, &)
  Async::Semaphore.new(concurrency || collection.count, parent:).then do |s|
    collection.map do |item|
      s.async { yield(item) }
    end.map(&:wait)
  end
end