================ @@ -642,26 +652,86 @@ ModuleSP DynamicLoaderDarwin::GetDYLDModule() { void DynamicLoaderDarwin::ClearDYLDModule() { m_dyld_module_wp.reset(); } +template <typename InputIterator, typename ResultType> +static std::vector<ResultType> parallel_map( + llvm::ThreadPoolInterface &threadPool, InputIterator first, + InputIterator last, + llvm::function_ref<ResultType( + const typename std::iterator_traits<InputIterator>::value_type &)> + transform) { + const auto size = std::distance(first, last); + std::vector<ResultType> results(size); + if (size > 0) { + llvm::ThreadPoolTaskGroup taskGroup(threadPool); + auto it = first; + for (ssize_t i = 0; i < size; ++i, ++it) { + taskGroup.async([&, i, it]() { results[i] = transform(*it); }); + } + taskGroup.wait(); + } + return results; +} ---------------- JDevlieghere wrote:
Do we really need these `map` helpers? I would imagine you could achieve the same thing with something like this: ``` TaskGroup task_group(...); for (...) if (is_parallel) task_group.async(lambda, args); else lambda(args); task_group.wait(); ``` https://github.com/llvm/llvm-project/pull/110646 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits