Acme-Fork-Lazy
view release on metacpan or search on metacpan
lib/Acme/Fork/Lazy.pm view on Meta::CPAN
=head1 SYNOPSIS
use Acme::Fork::Lazy qw/:all/;
use feature 'say';
###
# Single parallel calculation
my $foo = forked { expensive_calculation_to_do_in_parallel() };
# ...then (sooner or later...)
say $foo;
###
# Parallel map
my @list = map forked { sleep $_; $_*2 }, 1..10;
sleep 5; # gives enough time for first 5 elements to be calculated
say $_ for @list;
###
END {
wait_kids; # make sure we're not leaving behind any zombies
}
=head1 DESCRIPTION
We often want to fork a process with an expensive calculation. This involves making the child
( run in 3.702 seconds using v1.01-cache-2.11-cpan-9789f410c06 )