BGS::Limit - Background execution of subroutines in child processes with limit of child processes.
use BGS::Limit; my @foo; foreach my $i (1 .. 7) { bgs_call { # child process return "Start $i"; } bgs_back { # callback subroutine my $r = shift; push @foo, "End $i. Result: '$r'.\n"; }; } my $limit = 3; bgs_wait($limit); print foreach @foo;
If $limit == 0, child processes are not used.
Do not use $_ in bgs_call.
bgs_call do not return kid_pid, but count of kid processes.
BGS - Background execution of subroutines in child processes.
Nick Kostirya
Copyright (C) 2011 by Nick Kostirya
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.
To install BGS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm BGS
CPAN shell
perl -MCPAN -e shell install BGS
For more information on module installation, please visit the detailed CPAN module installation guide.