MooseX:...rs::Job(3)

πŸ“¦
version 0.24 Β· 2 versions
, in fedora 43

πŸ’– MooseX::Workers::Job πŸ’–

okay bestie so real talk β€” this page is from the User Contributed Perl Documentation collection, it's MooseX::Workers::Job(3), and it is exactly what it sounds like. let's get into it 🫢


✨ NAME ✨

MooseX::Workers::Job β€” literally just one of the jobs that MooseX::Workers is out here running. one job. that's the whole thing. no cap. πŸ’…


✨ SYNOPSIS ✨

here's the vibe, copy it, love it, run it:

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'

notice how the output order is not the order you spawned them? yeah. that's the whole point of workers, bestie. they do their own thing on their own time πŸ¦‹βœ¨


✨ DESCRIPTION ✨

so like, MooseX::Workers::Job objects are the move when you want to name each MooseX::Workers job, or when you want a job to timeout (abort) after a certain number of seconds. like a "you have 30 seconds to slay or you're done" situation. iconic behavior honestly πŸ‘‘


✨ METHODS ✨

the accessors, plus this one extra method:

is_coderef

returns true if the command is some type of coderef β€” and undef otherwise. that's it. that's the method. πŸŽ€


heads up bestie: this is a MooseX::Workers companion class, so if you don't already know your way around MooseX::Workers, maybe go read that one first? no pressure tho πŸ’œ

and that's the whole page!! ty for reading my little manpage rant, go name your jobs and set your timeouts, mwah πŸ˜­πŸ’–

this page shipped with perl v5.42.0, dated 2025-07-25 β€” so yeah, it's giving fresh, it's giving maintained, periodt 🌈⭐

πŸ“¦ where this page comes from