Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Execute $(1) with each entry of $(2) as variable "arg" in parallel, $(3) seconds timeout
- # ex $(call _parallel,some_parallel_task $$arg,apple pear orange,10)
- # will execute
- # some_parallel_task apple
- # some_parallel_task pear
- # some_parallel_task orange
- # in parallel each with a timeout for 10 seconds, and await completion
- define _parallel
- @rm -rf .parallel.pids
- @$(foreach arg,$(2), \
- arg=$(arg); \
- timeout $(3)s $(1) & \
- echo $$! >> .parallel.pids; \
- ) \
- while read pid; do \
- wait $$pid; \
- done <.parallel.pids
- @rm -rf .parallel.pids
- endef
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement