| 1 | |||||||||||
| 2 | package Proc::JobQueue::Sequence; | ||||||||||
| 3 | |||||||||||
| 4 | # $Id: Sequence.pm 13848 2009-07-23 21:34:00Z david $ | ||||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | use Proc::JobQueue::Job; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 2 | ▶ | use Hash::Util qw(lock_keys unlock_keys); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 2 | our @ISA = qw(Proc::JobQueue::Job); | |||||||||
| 11 | 2 | ▶ | use List::MoreUtils qw(all); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 2 | ▶ | use Scalar::Util qw(weaken); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 2 | ▶ | use Proc::JobQueue::DependencyTask; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | sub new | ||||||||||
| 16 | 5 | ▶ | { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 17 | 5 | my ($pkg, $opts, $config, @jobs) = @_; | |||||||||
| 18 | |||||||||||
| 19 | 5 | my $job = $pkg->SUPER::new( | |||||||||
| 20 | opts => $opts, | ||||||||||
| 21 | config => $config, | ||||||||||
| 22 | jobs => \@jobs, | ||||||||||
| 23 | priority => 20, | ||||||||||
| 24 | ); | ||||||||||
| 25 | 5 | return $job; | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | sub startup | ||||||||||
| 29 | 6 | ▶ | { | ||||||||
|
Subroutine
startup: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 30 | 6 | my $job = shift; | |||||||||
| 31 | |||||||||||
| 32 | 6 | my $graph = $job->{queue}->graph(); | |||||||||
| 33 | |||||||||||
| 34 | 6 | my @last = (); | |||||||||
| 35 | 6 | for my $subtask (@{$job->{jobs}}) { | |||||||||
| 36 | 72 | $graph->add($subtask, @last); | |||||||||
| 37 | 72 | @last = ( $subtask ); | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | my $finish = Proc::JobQueue::DependencyTask->new( | ||||||||||
| 41 | desc => 'mark Sequence as done', | ||||||||||
| 42 | 6 | ▶ | func => sub { | ||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||
| 43 | 6 | ▶ | $graph->remove_dependency($job) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | if $graph->is_dependency($job); | ||||||||||
| 45 | 6 | return 'done'; | |||||||||
| 46 | }, | ||||||||||
| 47 | 6 | ); | |||||||||
| 48 | |||||||||||
| 49 | 6 | $graph->add($finish, @last); | |||||||||
| 50 | |||||||||||
| 51 | 6 | $job->{queue}->job_part_finished($job, 0); | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | __END__ | ||||||||||