On Thursday 03 May 2012 16:12:17 John Kearney wrote: > I tend to do something more like this > > function runJobParrell { > local mjobCnt=${1} && shift > jcnt=0 > function WrapJob { > "${@}" > kill -s USR2 $$ > }
neat trick. all my parallel loops tend to have a fifo of depth N where i push on pids and when it gets full, wait for the first one. it works moderately well, except for when a slow job in the pipe chokes and the parent doesn't push anymore in until that clears. > function JobFinised { > jcnt=$((${jcnt}-1)) : $(( --jcnt )) or a portable version: : $(( jcnt -= 1 )) > while [ $# -gt 0 ] ; do > while [ ${jcnt} -lt ${mjobCnt} ]; do > jcnt=$((${jcnt}+1)) same math suggestion as above -mike
signature.asc
Description: This is a digitally signed message part.