Sha256: 66e2405b776d0422164136b25fdd6002b1977bbf96e6e7b0d1de93f02aa7d954
Contents?: true
Size: 782 Bytes
Versions: 1
Compression:
Stored size: 782 Bytes
Contents
# frozen_string_literal: true require_relative "tools/version" require "async" require "async/notification" require "async/semaphore" require "zeitwerk" loader = Zeitwerk::Loader.new loader.tag = File.basename(__FILE__, ".rb") loader.inflector = Zeitwerk::GemInflector.new(__FILE__) loader.push_dir(File.expand_path("..", __dir__.to_s)) module Async # Your code goes here... module Tools # rubocop:disable Style/ClassAndModuleChildren class Error < StandardError end end 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 end loader.setup loader.eager_load
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
async-tools-0.2.10 | lib/async/tools.rb |