Problem: Independent commands run sequentially; can't leverage multiple cores.
Solution: Add parallel execution block.
sh do
# Run commands in parallel, wait for all to complete
results = parallel do
grep("error", "log1.txt")
grep("error", "log2.txt")
grep("error", "log3.txt")
end
results.each { |r| puts r.stdout }
end
# With concurrency limit
sh do
parallel(max: 4) do
files.each { |f| gzip(f) }
end
end
# Fail-fast mode (stop all on first error)
sh do
parallel(fail_fast: true) do
test_suite_1
test_suite_2
test_suite_3
end
end
Implementation:
- Create
RubyShell::Parallel executor using threads or Process.fork
- Collect results from all parallel commands
- Add options for concurrency limit, fail-fast behavior
Problem: Independent commands run sequentially; can't leverage multiple cores.
Solution: Add parallel execution block.
Implementation:
RubyShell::Parallelexecutor using threads or Process.fork