Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Multi-core loops
- X-seq: zsh-users 14595
- From: Kazuo Teramoto <kaz.rag@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Multi-core loops
- Date: Sun, 22 Nov 2009 22:48:18 -0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=YfO4dMcCb866+yO/Fi+jFC+yovwcikEipf6bmEeW7pA=; b=Ioy1aam3O5x0DEtC3OQU/p2N8I5b/2+Mdy+32/GqcSaA1a+1RVS6R80U5yWfuygUoT Zv1c9+kyYIStSpRN5KvP371hDVL9Pg5Pc5Yi074dTsTjBj1E8iYpvMPtVC+rjz4DMut0 R/2XsBw6FYKokeZhN8iWRkAEYM2SAb2a28n7A=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=oBJKe4U7KUHHs9C9WOQN/Kd0kim3NecqvGNERReRt8j3wIyXpS6mRz9vIb3hdJhJSR SeNcZtsm129aDGaweppVQ3mkY1yAvT+Htzw8fKY+/Io84MG4UrXPp75JS6H2YyQOx0js 7JMullE+m8xEwi8O7i4+n9LRJ2OCqivZJYaD4=
- In-reply-to: <5992e17f0911221634y4b42d567lfd75c2782487b637@xxxxxxxxxxxxxx>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20090628103129.GA15270@xxxxxxxxxxxxxxxxxxxxxxxxxx> <5992e17f0911221305j53522ed6j55d8b1308fda2214@xxxxxxxxxxxxxx> <20091122221655.GA28699@xxxxxxxxxxxxxxxxxxxxxxxxxx> <237967ef0911221440u66a3b80dqcaa0717670397a9f@xxxxxxxxxxxxxx> <5992e17f0911221634y4b42d567lfd75c2782487b637@xxxxxxxxxxxxxx>
I found a pretty/small solution (but not optimized)
http://stackoverflow.com/questions/38160/parallelize-bash-script
I'm quoting the solution (the solution can be used as-is in zsh too)
> Here an alternative solution that can be inserted into .bashrc and used for
> everyday one liner:
>
> function pwait() {
> while [ $(jobs -p | wc -l) -ge $1 ]; do
> sleep 1
> done
> }
>
> To use it, all one has to do is put & after the jobs and a pwait call, the
> parameter gives the number of parallel processes:
>
> for i in *; do
> do_something $i &
> pwait 10
> done
>
> It would be nicer to use wait instead of busy waiting on the output of jobs
> -p, but there doesn't seem to be an obvious solution to wait till any of the
> given jobs is finished instead of a all of them.
>
--
ÂDans la vie, rien n'est à craindre, tout est à comprendreÂ
Marie Sklodowska Curie.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author