TaskPipe/Iterator.pm

filter: Statementstmt 90.9% 10 / 11 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod n/a totaltotal 85.7% 12 / 14 CC 1 SCAR 0.2
CC
1
Cov
91%
__ANON__
1.0
__ANON__
1.0
BEGIN
1.0
CRAP 1.0
« TaskPipe/PathSettings/Global.pm ↑ Summary TaskPipe/JobManager/Settings.pm »
1 package TaskPipe::Iterator;
2  
3 38 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 38 with 'MooseX::ConfigCascade';
5  
6  
7 38 has 'next' => (is => 'rw', isa => 'CodeRef');
8 38 has 'reset' => (is => 'rw', isa => 'CodeRef');
9 0 ▶has 'count' => (is => 'rw', isa => 'CodeRef', default => sub{sub{return -1}});
Subroutine __ANON__: not called CC=1 SCAR=0.4
Subroutine __ANON__: called CC=1 SCAR=0.4
10  
11  
12 =head1 NAME
13  
14 TaskPipe::Iterator - generic class for TaskPipe Iterators
15  
16 =head1 DESCRIPTION
17  
18 If you are creating an iterator, you can either get a new instance
19 of a generic iterator and then supply the subs:
20  
21 my $iterator = TaskPipe::Iterator->new(
22  
23 next => sub{
24 #...
25 },
26  
27 count => sub {
28 #...
29 },
30  
31 reset => sub {
32 # ...
33 }
34  
35 );
36  
37 or you can inherit from L<TaskPipe::Iterator> and override the subs. All 3 subs must be provided - however
38  
39 =head1 SUBS
40  
41 =head2 next
42  
43 This sub should iterate the record pointer and return the next record
44  
45 =head2 reset
46  
47 This sub should reset the record pointer to the first record.
48  
49 =head2 count
50  
51 Optional. If you know how many records you are expecting, then this sub should return this value. Including C<count> offers a small performance boost by using the parent thread to execute the last record instead of idling. If the total number of records is not known in advance (often the case with iterators) then this sub should return -1. A sub that returns -1 is the default - so you can just omit this attribute if you don't have a way to calculate the total number of results.
52  
53 =head1 AUTHOR
54  
55 Tom Gracey <tomgracey@gmail.com>
56  
57 =head1 COPYRIGHT AND LICENSE
58  
59 Copyright (c) Tom Gracey 2018
60  
61 TaskPipe is free software, licensed under
62  
63 The GNU Public License Version 3
64  
65 =cut
66  
67  
68 38 __PACKAGE__->meta->make_immutable;
69 38 1;
70  
« TaskPipe/PathSettings/Global.pm ↑ Summary TaskPipe/JobManager/Settings.pm »