| 1 | package Analizo::Batch::Runner; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use parent qw(Class::Accessor::Fast); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 5 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 6 | 5 | my ($class, @args) = @_; | |||||||||
| 7 | 5 | return bless { @args }, $class; | |||||||||
| 8 | } | ||||||||||
| 9 | |||||||||||
| 10 | 3 | ▶ | sub run($$$) { | ||||||||
|
Subroutine
run: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 11 | 3 | my ($self, $batch, $output) = @_; | |||||||||
| 12 | 3 | $output->initialize(); | |||||||||
| 13 | 3 | $self->actually_run($batch, $output); | |||||||||
| 14 | 3 | $output->flush(); | |||||||||
| 15 | } | ||||||||||
| 16 | |||||||||||
| 17 | # must be implemented by subclasses. Will receive as argument: | ||||||||||
| 18 | # | ||||||||||
| 19 | # * the batch to be run | ||||||||||
| 20 | # * the output object | ||||||||||
| 21 | # | ||||||||||
| 22 | # This method must iterate over the jobs in some way, depending on the strategy | ||||||||||
| 23 | # employed by the subclass, call I<execute> on each job, and feed the job | ||||||||||
| 24 | # object to the $output object by calling I<$output->push($job)>. In the end, | ||||||||||
| 25 | # the runner must call flush() on the output object. | ||||||||||
| 26 | 1 | ▶ | sub actually_run { | ||||||||
|
Subroutine
actually_run: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 2 | __PACKAGE__->mk_accessors(qw( progress )); | |||||||||
| 30 | |||||||||||
| 31 | 3 | ▶ | sub report_progress { | ||||||||
|
Subroutine
report_progress: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 32 | 3 | my ($self, $job, $i, $n) = @_; | |||||||||
| 33 | 3 | my $progress = $self->progress; | |||||||||
| 34 | 3 | ▶ | if ($progress) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | 1 | &$progress($job, $i, $n); | |||||||||
| 36 | } | ||||||||||
| 37 | } | ||||||||||
| 38 | |||||||||||
| 39 | 2 | 1; | |||||||||