Module: Pod::PodGenerate::Patches::CacheAnalyzerPatch::ParallelCacheKeyComputation
- Defined in:
- lib/cocoapods-podgenerate/patches/cache_analyzer_patch.rb
Instance Method Summary collapse
-
#create_cache_key_mappings(target_by_label) ⇒ Object
Override create_cache_key_mappings to parallelize MD5 computation The original iterates target_by_label sequentially, computing cache keys.
Instance Method Details
#create_cache_key_mappings(target_by_label) ⇒ Object
Override create_cache_key_mappings to parallelize MD5 computation The original iterates target_by_label sequentially, computing cache keys. Since each target is independent, we use a thread pool.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/cocoapods-podgenerate/patches/cache_analyzer_patch.rb', line 31 def create_cache_key_mappings(target_by_label) UI. '- Creating cache key mappings (parallel)' do pool_size = compute_pool_size pool = Concurrent::FixedThreadPool.new(pool_size) mutex = Mutex.new results = {} target_by_label.each do |label, target| pool.post do key = case target when PodTarget local = sandbox.local?(target.pod_name) = sandbox.checkout_sources[target.pod_name] TargetCacheKey.from_pod_target(sandbox, target_by_label, target, :is_local_pod => local, :checkout_options => ) when AggregateTarget TargetCacheKey.from_aggregate_target(sandbox, target_by_label, target) else raise "[BUG] Unknown target type #{target}" end mutex.synchronize { results[label] = key } rescue StandardError => e mutex.synchronize do Pod::UI.warn "[cocoapods-podgenerate] Cache key computation error: #{e.}" end end end pool.shutdown pool.wait_for_termination results end end |