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()

$job->is_finished()

$job->cancelled()

DESCRIPTION

This is the base class for the $job objects used by Proc::JobQueue.

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()
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, finished() will be invoked.

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.

is_finished

Returns true: it's only called when the job is expected to be finished. Used by Proc::JobQueue::CommandQueue and Proc::JobQueue::Sequence.

cancelled

Returns false. Used by Proc::JobQueue::CommandQueue and Proc::JobQueue::Sequence

SEE ALSO

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

LICENSE

This package may be used and redistributed under the terms of either the Artistic 2.0 or LGPL 2.1 license.