Parallel::ForkManager can do what you want.
With adjustments and subs to fit your purpose.use Parallel::ForkManager; my $max = 3; my %cids = (); my $forker = new Parallel::ForkManager($max); while (<REQUEST>) { if (pressure() > 0) { $max = $forker->set_max_procs( $max + 3) ; } elsif {pressure() < 0) { $max = 1 + scalar( keys %cids); $forker->set_max_procs( $max); } if (my $pid = $forker->start()) { ++$cids{$pid}; next; } act_on($_); $forker->finish(); } $forker->wait_on_children();
After Compline,
Zaxo
In reply to Re: Forking a new Process
by Zaxo
in thread Forking a new Process
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |