JobQueue/BackgroundQueue.pm

filter: Statementstmt 77.7% 35 / 45 Branchbran 40.0% 4 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 50.0% 1 / 2 totaltotal 73.0% 46 / 63 CC 8 SCAR 21.4
CC
8
Cov
71%
finish
13.2
BEGIN
1.0
BEGIN
1.0
CRAP 8.5
« JobQueue/EventQueue.pm ↑ Summary JobQueue/DependencyQueue.pm »
1  
2 package Proc::JobQueue::BackgroundQueue;
3  
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use Carp qw(confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Time::HiRes qw(sleep);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 require Proc::JobQueue;
9  
10 3 our @ISA = qw(Proc::JobQueue);
11  
12 3 our $debug = $Proc::JobQueue::debug;
13  
14 sub new
15 2 ▶{
Subroutine new: called CC=1 SCAR=0.0
Pod documented
16 2 my ($pkg, %params) = @_;
17 2 my $queue = $pkg->SUPER::new(sleeptime => 2, %params);
18 }
19  
20 sub finish
21 2 ▶{
Subroutine finish: called CC=8 SCAR=25.8
Pod undocumented
22 2 my $queue = shift;
23 2 for(;;) {
24 43 $queue->checkjobs();
25 43 ▶ return if $queue->startmore();
Branch: 1 branch
BranchTrueFalseTotal
if $queue->startmore 2 41 43
26  
27 41 my $running = 0;
28 41 my $queued = keys %{$queue->{queue}};
29 41 for my $host (@{$queue->{hosts}}) {
30 41 my $hr = $queue->{status}{$host};
31 41 $running += keys %{$hr->{running}};
32 41 $queued += keys %{$hr->{queue}};
33 }
34  
35 41 ▶ if ($debug > 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Proc::JobQueue::BackgroundQueue::debug > 2) 0 41 41
36 0 print STDERR "Finish loop top: $running running, $queued queued\n";
37 0 for my $host (@{$queue->{hosts}}) {
38 0 my $hr = $queue->{status}{$host};
39 0 ▶ print "running: " . join(", ", map { $_ . ": " . $hr->{running}{$_}{desc} } keys %{$hr->{running}} ) . "\n" if $running;
Branch: 1 branch
BranchTrueFalseTotal
if $running 0 0 0
40 0 ▶ print "queued: " . join(", ", map { $_ . ": " . $hr->{running}{$_}{desc} } keys %{$hr->{queue}} ) . "\n" if $queued;
Branch: 1 branch
BranchTrueFalseTotal
if $queued 0 0 0
41 }
42 }
43  
44 41 ▶ print "Jobs are waiting to be run, but none are running\n" unless $running;
Branch: 1 branch
BranchTrueFalseTotal
unless $running 0 41 41
45 41 sleep($queue->{sleeptime});
46 }
47 }
48  
49 3 1;
50  
51 __END__
« JobQueue/EventQueue.pm ↑ Summary JobQueue/DependencyQueue.pm »