BGS::Future - Background execution of subroutines in child processes.
use BGS::Future; my $f = future { "from $$\n" }; print $$, " got result ", $f->(); print $$, " has result ", $f->(); my $z = future { sleep 10; "from $$\n" }; $z->cancel(); print $$, " got result ", $_->() foreach map { future { "$_ from $$\n" }; } 1 .. 3;
It's BGS wrapper.
Call subroutine in child process.
my $f = future { "from $$\n" };
or
my $f = BGS::Future->new(sub { "from $$\n" });
Get result.
my $r = $f->();
my $r = $f->join();
Kill child processes.
$f->cancel();
Set $BGS::limit to limit child processes count. Default is 0 (unlimited).
Nick Kostyria
Copyright (C) 2017 by Nick Kostyria
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.