in reply to fork and mailing lists
Just keep your $MAX_PROCESSES at something reasonable for your system, and all should be fine.use Parallel::ForkManager; # Max number or processes you want to fork at one time. # Set this to something reasonable so you don't thrash your box. my $MAX_PROCESSES = 5; # J. Random list of numbers. my @things = (1..10); my $pm = new Parallel::ForkManager($MAX_PROCESSES); # Start looping through my list of numbers foreach my $thing (@things) { # This is more of a loud comment than anything else, # just telling you that the parent is about to # fork a child. print "Forking off $thing...\n"; # Kick off the child process. # If this is the parent process, # we'll move on to the next step in this loop $pm->start and next; # This is your child process. # There are many like it, but this one is yours. :) # Do your forked goodness here print "$thing\n"; $pm->finish; # The child has finished. Tell him to clean up his room. } $pm->wait_all_children;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: fork and mailing lists
by Anonymous Monk on Nov 03, 2001 at 21:10 UTC |