| 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
| |||||||||||
| 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
| |||||||||||
| 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
| |||||||||||
| 40 | 0 | ▶ | print "queued: " . join(", ", map { $_ . ": " . $hr->{running}{$_}{desc} } keys %{$hr->{queue}} ) . "\n" if $queued; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | } | ||||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 41 | ▶ | print "Jobs are waiting to be run, but none are running\n" unless $running; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 45 | 41 | sleep($queue->{sleeptime}); | |||||||||
| 46 | } | ||||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | 3 | 1; | |||||||||
| 50 | |||||||||||
| 51 | __END__ | ||||||||||