Content

5.13.04
poor man’s threads

13 May 2004 by bn
Filed under geeky

this is easily the most useful perl module i’ve found in recent history: Parallel::ForkManager. doing something in parallel without the overhead of actually writing really multithreaded code is quite cool.

use Parallel::ForkManager;
$pm = new Parallel::ForkManager($MAX_PROCESSES);

foreach $data (@all_data) {
# Forks and returns the pid for the child:
my $pid = $pm->start and next;
work goes here
$pm->finish; # Terminates the child process
}

highly inelegant and hardly clean, but damn this is useful.

Scroll up

Comment on
poor man’s threads

»
»
»

Tags you can use: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>