| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Parallel::ForkManager::Segmented; |
|
2
|
|
|
|
|
|
|
$Parallel::ForkManager::Segmented::VERSION = '0.8.0'; |
|
3
|
21
|
|
|
21
|
|
1478771
|
use strict; |
|
|
21
|
|
|
|
|
205
|
|
|
|
21
|
|
|
|
|
636
|
|
|
4
|
21
|
|
|
21
|
|
105
|
use warnings; |
|
|
21
|
|
|
|
|
42
|
|
|
|
21
|
|
|
|
|
490
|
|
|
5
|
21
|
|
|
21
|
|
484
|
use 5.014; |
|
|
21
|
|
|
|
|
73
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
21
|
|
|
21
|
|
9545
|
use parent 'Parallel::ForkManager::Segmented::Base'; |
|
|
21
|
|
|
|
|
7031
|
|
|
|
21
|
|
|
|
|
116
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
21
|
|
|
21
|
|
33277
|
use Parallel::ForkManager (); |
|
|
21
|
|
|
|
|
1788954
|
|
|
|
21
|
|
|
|
|
5500
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub run |
|
12
|
|
|
|
|
|
|
{ |
|
13
|
21
|
|
|
21
|
1
|
22472
|
my ( $self, $args ) = @_; |
|
14
|
|
|
|
|
|
|
|
|
15
|
21
|
|
|
|
|
159
|
my $processed = $self->process_args($args); |
|
16
|
21
|
100
|
|
|
|
774
|
return if not $processed; |
|
17
|
|
|
|
|
|
|
my ( $WITH_PM, $batch_cb, $batch_size, $nproc, $stream_cb, ) = |
|
18
|
20
|
|
|
|
|
55
|
@{$processed}{qw/ WITH_PM batch_cb batch_size nproc stream_cb /}; |
|
|
20
|
|
|
|
|
95
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
20
|
|
|
|
|
40
|
my $pm; |
|
21
|
|
|
|
|
|
|
|
|
22
|
20
|
50
|
|
|
|
70
|
if ($WITH_PM) |
|
23
|
|
|
|
|
|
|
{ |
|
24
|
20
|
|
|
|
|
150
|
$pm = Parallel::ForkManager->new($nproc); |
|
25
|
|
|
|
|
|
|
} |
|
26
|
20
|
|
|
|
|
85790
|
my $batch = $stream_cb->( { size => 1 } )->{items}; |
|
27
|
20
|
50
|
|
|
|
365
|
return if not defined $batch; |
|
28
|
20
|
|
|
|
|
95
|
$batch_cb->($batch); |
|
29
|
|
|
|
|
|
|
ITEMS: |
|
30
|
20
|
|
|
|
|
32080
|
while ( |
|
31
|
|
|
|
|
|
|
defined( $batch = $stream_cb->( { size => $batch_size } )->{items} ) ) |
|
32
|
|
|
|
|
|
|
{ |
|
33
|
56
|
50
|
|
|
|
2820
|
if ($WITH_PM) |
|
34
|
|
|
|
|
|
|
{ |
|
35
|
56
|
|
|
|
|
576
|
my $pid = $pm->start; |
|
36
|
|
|
|
|
|
|
|
|
37
|
56
|
100
|
|
|
|
8127653
|
if ($pid) |
|
38
|
|
|
|
|
|
|
{ |
|
39
|
40
|
|
|
|
|
1719
|
next ITEMS; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
} |
|
42
|
16
|
|
|
|
|
583
|
$batch_cb->($batch); |
|
43
|
16
|
50
|
|
|
|
73144
|
if ($WITH_PM) |
|
44
|
|
|
|
|
|
|
{ |
|
45
|
16
|
|
|
|
|
1580
|
$pm->finish; # Terminates the child process |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
} |
|
48
|
4
|
50
|
|
|
|
640
|
if ($WITH_PM) |
|
49
|
|
|
|
|
|
|
{ |
|
50
|
4
|
|
|
|
|
154
|
$pm->wait_all_children; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
4
|
|
|
|
|
4007535
|
return; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |