table of contents
other versions
- Tumbleweed 0.24-1.35
- Leap-15.6
| MooseX::Workers::Job(3) | User Contributed Perl Documentation | MooseX::Workers::Job(3) |
NAME¶
MooseX::Workers::Job - One of the jobs MooseX::Workers is running
SYNOPSIS¶
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'
DESCRIPTION¶
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.
METHODS¶
The accessors, as well as:
is_coderef¶
Returns true if the command is some type of coderef, undef otherwise.
| 2015-04-14 | perl v5.42.0 |