NAME
BGS::Limit - Background execution of subroutines in child processes with limit of child processes.
SYNOPSIS
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.
ATTENTION
Do not use $_ in bgs_call.
bgs_call do not return kid_pid, but count of kid processes.
SEE
BGS - Background execution of subroutines in child processes.
AUTHOR
Nick Kostirya
COPYRIGHT AND LICENSE
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.