| 1 | |||||||||||||||||||||||||||||
| 2 | package Proc::JobQueue::DependencyQueue; | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Carp qw(confess); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | require Proc::JobQueue; | |||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Time::HiRes qw(time); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Object::Dependency; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | require POSIX; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | our @ISA = qw(Proc::JobQueue); | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | our $timer_interval = 6; | |||||||||||||||||||||||||||
| 15 | 1 | my $debug = 0; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | sub new | ||||||||||||||||||||||||||||
| 18 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=15.6
Pod
documented
| |||||||||||||||||||||||||||||
| 19 | 1 | my ($pkg, %params) = @_; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | ▶ | $params{dependency_graph} ||= Object::Dependency->new(); | ||||||||||||||||||||||||||
|
Condition33%1/3
$params{"dependency_graph"} ||= "Object::Dependency"->new
MC/DC0%0/2
$params{"dependency_graph"} ||= "Object::Dependency"->new
$params{"dependency_graph"}
"Object::Dependency"->new
Truth table33%1/3
A ||= B
A= $params{"dependency_graph"}B= "Object::Dependency"->new
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 1 | my $queue = $pkg->SUPER::new( | |||||||||||||||||||||||||||
| 24 | startmore_in_progress => 0, | ||||||||||||||||||||||||||||
| 25 | on_failure => \&on_failure, | ||||||||||||||||||||||||||||
| 26 | %params | ||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 1 | ▶ | if (defined(&IO::Event::unloop_all)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | 1 | my $last_dump = time; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | my $timer = IO::Event->timer( | ||||||||||||||||||||||||||||
| 33 | interval => $params{timer_interval} || $timer_interval, | ||||||||||||||||||||||||||||
| 34 | 1 | ▶ | cb => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=20.1
| |||||||||||||||||||||||||||||
| 35 | 1 | ▶ | print STDERR "beep!\n" if $debug; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 1 | eval { | |||||||||||||||||||||||||||
| 37 | 1 | $queue->startmore; | |||||||||||||||||||||||||||
| 38 | }; | ||||||||||||||||||||||||||||
| 39 | 1 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | print STDERR "DIE DIE DIE DIE DIE (DT1): $@"; | |||||||||||||||||||||||||||
| 41 | # exit 1; hangs | ||||||||||||||||||||||||||||
| 42 | 0 | POSIX::_exit(1); | |||||||||||||||||||||||||||
| 43 | }; | ||||||||||||||||||||||||||||
| 44 | 1 | ▶ | if ($debug && time > $last_dump + $timer_interval) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$debug and &Proc::JobQueue::DependencyQueue::time() > $last_dump + $Proc::JobQueue::DependencyQueue::timer_interval
MC/DC0%0/2
$debug and &Proc::JobQueue::DependencyQueue::time() > $last_dump + $Proc::JobQueue::DependencyQueue::timer_interval
$debug
&Proc::JobQueue::DependencyQueue::time() > $last_dump + $Proc::JobQueue::DependencyQueue::timer_interval
Truth table33%1/3
A and B
A= $debugB= &Proc::JobQueue::DependencyQueue::time() > $last_dump + $Proc::JobQueue::DependencyQueue::timer_interval
| |||||||||||||||||||||||||||||
| 45 | 0 | $params{dependency_graph}->dump_graph(); | |||||||||||||||||||||||||||
| 46 | 0 | $last_dump = time; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | 1 | ▶ | use POSIX ":sys_wait_h"; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 49 | 1 | my $k; | |||||||||||||||||||||||||||
| 50 | 1 | ▶ | do { $k = waitpid(-1, WNOHANG) } while $k > 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | }, | ||||||||||||||||||||||||||||
| 52 | 1 | ▶ | ); | ||||||||||||||||||||||||||
|
Condition33%1/3
$params{'timer_interval'} || $Proc::JobQueue::DependencyQueue::timer_interval
MC/DC0%0/2
$params{'timer_interval'} || $Proc::JobQueue::DependencyQueue::timer_interval
$params{'timer_interval'}
$Proc::JobQueue::DependencyQueue::timer_interval
Truth table33%1/3
A || B
A= $params{'timer_interval'}B= $Proc::JobQueue::DependencyQueue::timer_interval
| |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | $Event::DIED = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 55 | 0 | Event::verbose_exception_handler(@_); | |||||||||||||||||||||||||||
| 56 | 0 | IO::Event::unloop_all(); | |||||||||||||||||||||||||||
| 57 | 1 | }; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 1 | return $queue; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | sub unloop | ||||||||||||||||||||||||||||
| 64 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
unloop: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 65 | 0 | my ($queue) = @_; | |||||||||||||||||||||||||||
| 66 | 0 | ▶ | if (defined(&IO::Event::unloop_all)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 0 | IO::Event::unloop_all(); | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | sub on_failure | ||||||||||||||||||||||||||||
| 72 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
on_failure: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 73 | 0 | my ($queue, $job, @exit_code) = @_; | |||||||||||||||||||||||||||
| 74 | 0 | ▶ | if ($job->{on_failure}) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 75 | 0 | $job->{on_failure}->(@exit_code); | |||||||||||||||||||||||||||
| 76 | } elsif ($job->{errors}) { | ||||||||||||||||||||||||||||
| 77 | 0 | $job->{errors}->("FAILED: $job->{desc}", @exit_code); | |||||||||||||||||||||||||||
| 78 | } else { | ||||||||||||||||||||||||||||
| 79 | 0 | print STDERR "JOB $job->{desc} FAILED\nexit @exit_code\n"; | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 1 | 1; | |||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | __END__ | ||||||||||||||||||||||||||||