in reply to Re: Parallel tasks
in thread Parallel tasks

That can't be right? All 3 proceesses are processing all 5 collections.

Replies are listed 'Best First'.
Re^3: Parallel tasks
by tachyon (Chancellor) on Jul 12, 2004 at 12:34 UTC

    Rubbish. Perhaps this slightly modified code will help you see what is happening more easily:

    C:\>type test.pl use Parallel::ForkManager; my @collections = qw (col1 col2 col3 col4 col5); my $max_tasks = 3; $pm = new Parallel::ForkManager($max_tasks); $|++; my $start = time(); for my $collection (@collections) { my $pid = $pm->start and next; printf "Begin processing $collection at %d secs.....\n", time()-$s +tart; sleep rand(5)+2; printf ".... $collection done at %d secs!\n", time()-$start; $pm->finish; } C:\>perl test.pl Begin processing col1 at 0 secs..... Begin processing col2 at 0 secs..... Begin processing col3 at 0 secs..... .... col3 done at 3 secs! Begin processing col4 at 3 secs..... .... col1 done at 4 secs! Begin processing col5 at 4 secs..... .... col2 done at 5 secs! .... col4 done at 6 secs! .... col5 done at 9 secs! C:\>

    cheers

    tachyon