in reply to Re^6: Please Explain the Parallel::ForkManager Idiom my $pid = $pm->start and next;
in thread Please Explain the Parallel::ForkManager Idiom my $pid = $pm->start and next;
Please rip the script to shreds
This subroutine is pointless.
You are invoking an external program via system in order to sleep, but you are adding a first argument of 1 to that call to system, which means the external program is run asynchronously and the subroutine returns immediately:
sub take_nap { my $nap_duration = int rand $MAXIMUM_NAP_TIME; return system 1, "sleep $nap_duration"; }
Why, when you want to create a delay, are you calling it asynchronously?
But, more to the point, why are you calling an external program in order to sleep, when perl has a built-in sleep?
(You are aware that using fork on Windows means you're actually not forking a process but spawning a thread don't you?)
|
|---|