NAME
BGS::Future - Background execution of subroutines in child processes.
SYNOPSIS
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;
DESCRIPTION
It's BGS wrapper.
future or new
Call subroutine in child process.
my $f = future { "from $$\n" };
or
my $f = BGS::Future->new(sub { "from $$\n" });
join
Get result.
my $r = $f->();
or
my $r = $f->join();
cancel
Kill child processes.
$f->cancel();
$BGS::limit
Set $BGS::limit to limit child processes count. Default is 0 (unlimited).
AUTHOR
Nick Kostyria
COPYRIGHT AND LICENSE
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.