David Muir Sharnoff > Proc-JobQueue-0.903 > Proc::JobQueue::DependencyJob

Download:
modules/Proc-JobQueue-0.903.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Source  

NAME ^

 Proc::JobQueue::DependencyJob - dependency-aware job object for Proc::JobQueue

SYNOPSIS ^

 use Proc::JobQueue::DependencyJob;
 use Object::Dependency;

 $graph = Object::Dependency->new()

 $job = Proc::JobQueue::DependencyJob->new($graph, $callback_func, %params);

 $job->startup()

 $job->job_part_finished()

 $job->jobdone();

 $job->failure(@exit_code)

DESCRIPTION ^

Proc::JobQueue::DependencyJob is a subclass of Proc::JobQueue::Job used to define jobs to run from a Proc::JobQueue.

DependencyJob jobs are perl objects with a callback API. $job->startup() is called to start the job. That in turn calls, the callback provided in construction. The $job object is added to the argument list for the callback.

The return value from the callback lets startup() know what to do next: the job is finished; the job finished but it remains a dependency in the dependency graph; the job is not done but it should be removed from the dependency graph; or the job is not done and should remain in the dependency graph.

If the job is not done, then it needs to signal it's completion later by calling $job->finished(0) or $job->failure($reason).

CONSTRUCTION ^

These jobs require a dependency graph for construction. The %params parameter represents additional parameters passed to Proc::JobQueue::Job.

METHODS ^

In addition to the methods in Proc::JobQueue::Job, DependencyJob provides:

startup()

This is called by Proc::JobQueue::Job::start(). It calls the callback. The callback must return. A reference to self ($job) is provided as an argument to the callback. The return value from the callback must be a string from the following set:

all-done

The job has completed and the dependency in the dependency graph should be removed.

all-keep

The job has not completed and the dependency in the dependency graph should be kept.

The job can be marked as done with:

 $job->job_part_finished($do_startmore)

The dependency can be marked as completed with:

 $job->{dependency_graph}->remove_dependency($job);

Or both the job and the dependency can be marked as done/completed with one call:

 $job->finished(0);
job-done,dep-keep

The job has completed, but it should not be removed from the dependency graph. Somehow the callback must arrange that the dependency graph dependency gets removed later:

 $job->{dependency_graph}->remove_dependency($job);
job-keep,dep-done

The job is not done, but the dependency has been been fullfilled. The job can be marked done with:

 $job->finished(0);

Or

 $job->job_part_finished($do_startmore)

Things which depend on this job are eligible to be started.

failed()

This overrides JobQueue::Job's failure() method to mark the dependency as stuck.

failure(@reason)

This marks this job as failed.

SEE ALSO ^

Proc::JobQueue::EventQueue Proc::JobQueue::Job Proc::JobQueue::DependencyTask Proc::JobQueue

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.

syntax highlighting: