MooseX::Workers::Job - One of the jobs MooseX::Workers is running
package Manager; use Moose; with qw(MooseX::Workers); sub worker_stdout { my ( $self, $output, $job ) = @_; printf( "%s(%s,%s) said '%s'\n", $job->name, $job->ID, $job->PID, $output ); } sub run { foreach (qw( foo bar baz )) { my $job = MooseX::Workers::Job->new( name => $_, command => sub { print "Hello World\n" }, timeout => 30, ); $_[0]->spawn( $job ); } POE::Kernel->run(); } no Moose; Manager->new()->run(); # bar(2,32423) said 'Hello World' # foo(1,32422) said 'Hello World' # baz(3,32424) said 'Hello World'
MooseX::Workers::Job objects are convenient if you want to name each MooseX::Workers job, or if you want them to timeout (abort) after a certain number of seconds.
To install MooseX::Workers, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::Workers
CPAN shell
perl -MCPAN -e shell install MooseX::Workers
For more information on module installation, please visit the detailed CPAN module installation guide.