The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Proc::JobQueue::Job - The $job objects for Proc::JobQueue

SYNOPSIS

 $job = Proc::JobQueue::Job->new(%params)

 $job->can_command()

 $job->can_callback()

 $job->start()

 $job->host($host)
 $job->host()

 $job->jobnum($jobnum)
 $job->jobnum()

 $job->queue($queue)
 $job->queue()

 $job->runnable()

 $job->finished()

 $job->success()

 $job->addpostcb()

DESCRIPTION

This is the base class for the $job objects used by Proc::JobQueue. It supports running jobs in the background with Proc::Background. This class is designed to be overloaded. Only the start and checkjob methods use Proc::Background.

CONSTRUCTION

The parameters for new() are:

desc

Sets a description for this job.

priority (default: 100)

Sets a priority for this job. Higher number is higher priority. Jobs with higher priorities will be run first.

queue

A Proc::JobQueue object, used for calling $queue->jobdone(). Usually set by Proc::JobQueue::startjob(). This can also be set by calling queue($queue).

jobnum

A job number. Usually set by Proc::JobQueue::startjob(). This can also be set by calling jobnum($jobnum).

host

The host this job will run on. Usually set by Proc::JobQueue::startjob(). This can also be set by calling jobnum($jobnum).

generate_command

A function callback to generate a unix command for this job.

callback

A function callback that is this job. The callback will be called when the job should run. The job will be passed as the argument to the callback.

 $job->callback($job).
on_failure

A function callback that will be invoked only if the job fails.

 $on_failure->($job, @exit_code)

METHODS

checkjob()

A return value of undef indicates the job is still running. A defined value is the exit code for the job.

start

Starts this job. This is usually called by Proc::JobQueue::startjob().

host, jobnum, queue

Get or set (if provided with a defined parameter) the host, jobnum, or queue parameter for the job.

runnable

Returns true if the job is runnable at this time.

checkjob

Checks to see if the job is still running. This only really works with jobs which are unix commands. If the job is done, checkjob() will invoke finished().

finished(@exit_code)

Called to signal that the job has completed. If $exit_code[0] is true, then the job is considered to have failed and failed() will be invoked. Otherwise, sucess() will be called. In either case the post callback (if any), $queue->jobdone and $queue->startmore will be invoked.

sucess()

Called when the job succeeds. Doesn't do anything -- it's a hook to override.

failed

Called when the job failes. Invokes the on_failure action if there is one.

addpostcb($callback, @args)

Add a callback to be called when the job completes.

The $job object and the @exit_code will be added to the callback's arguments.

SEE ALSO

Proc::JobQueue Proc::JobQueue::DependencyJob Proc::JobQueue::RemoteDependencyJob Proc::JobQueue::Command Proc::JobQueue::Sort Proc::JobQueue::Move Proc::JobQueue::Sequence

LICENSE

Copyright (C) 2007-2008 SearchMe, Inc. Copyright (C) 2008-2010 David Sharnoff. Copyright (C) 2011 Google, Inc. This package may be used and redistributed under the terms of either the Artistic 2.0 or LGPL 2.1 license.