line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
######################################################################## |
2
|
|
|
|
|
|
|
# housekeeping |
3
|
|
|
|
|
|
|
######################################################################## |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Parallel::Queue::Manager v4.0.2; |
6
|
85
|
|
|
85
|
|
137540
|
use v5.24; |
|
85
|
|
|
|
|
257
|
|
7
|
85
|
|
|
85
|
|
612
|
use mro qw( c3 ); |
|
85
|
|
|
|
|
137
|
|
|
85
|
|
|
|
|
458
|
|
8
|
|
|
|
|
|
|
|
9
|
85
|
|
|
85
|
|
36002
|
use Parallel::Queue qw( noexport ); |
|
85
|
|
|
|
|
193
|
|
|
85
|
|
|
|
|
1378
|
|
10
|
|
|
|
|
|
|
|
11
|
85
|
|
|
85
|
|
511
|
use mro::EVERY; |
|
85
|
|
|
|
|
158
|
|
|
85
|
|
|
|
|
352
|
|
12
|
|
|
|
|
|
|
|
13
|
85
|
|
|
85
|
|
2091
|
use Carp qw( croak ); |
|
85
|
|
|
|
|
138
|
|
|
85
|
|
|
|
|
4323
|
|
14
|
85
|
|
|
85
|
|
453
|
use Scalar::Util qw( blessed reftype ); |
|
85
|
|
|
|
|
149
|
|
|
85
|
|
|
|
|
50202
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
######################################################################## |
17
|
|
|
|
|
|
|
# package variables |
18
|
|
|
|
|
|
|
######################################################################## |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our @CARP_NOT = ( __PACKAGE__, qw( mro mro::EVERY ) ); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $parent_pid = $$; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
######################################################################## |
25
|
|
|
|
|
|
|
# methods |
26
|
|
|
|
|
|
|
######################################################################## |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub handler : lvalue |
29
|
|
|
|
|
|
|
{ |
30
|
2159
|
|
|
2159
|
0
|
4635
|
my $qmgr = shift; |
31
|
2159
|
50
|
|
|
|
9960
|
@_ or return $qmgr->[0]; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
0
|
my $handler = shift; |
34
|
|
|
|
|
|
|
|
35
|
0
|
0
|
|
|
|
0
|
'CODE' eq reftype $handler |
36
|
|
|
|
|
|
|
or croak "handler: '$handler' is not CODE."; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
0
|
$qmgr->[0] = $handler |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub queue : lvalue |
42
|
|
|
|
|
|
|
{ |
43
|
4107
|
|
|
4107
|
0
|
11360
|
my $qmgr = shift; |
44
|
4107
|
50
|
100
|
|
|
31321
|
@_ or return $qmgr->[1] ||= []; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
0
|
$qmgr->[1] = shift |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub next |
50
|
|
|
|
|
|
|
{ |
51
|
2762
|
|
|
2762
|
0
|
4522
|
my $qmgr = shift; |
52
|
2762
|
|
|
|
|
6741
|
my $queue = $qmgr->queue; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# the caller may want undef as an argument, who knows? |
55
|
|
|
|
|
|
|
# only fix is an exception to indicate no further jobs. |
56
|
|
|
|
|
|
|
|
57
|
2762
|
100
|
|
|
|
14419
|
@$queue |
58
|
|
|
|
|
|
|
? shift @$queue |
59
|
|
|
|
|
|
|
: die "Empty queue.\n" |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub configure |
63
|
|
|
|
|
|
|
{ |
64
|
500
|
|
|
500
|
0
|
2507
|
my $handler = Parallel::Queue->can( 'configure' ); |
65
|
500
|
|
|
|
|
897
|
my $qmgr = shift; |
66
|
|
|
|
|
|
|
|
67
|
500
|
|
|
|
|
1912
|
$handler->( @_, qw( noexport ) ); |
68
|
|
|
|
|
|
|
|
69
|
500
|
|
|
|
|
15541
|
$qmgr |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub runqueue |
73
|
|
|
|
|
|
|
{ |
74
|
500
|
|
|
500
|
0
|
1642
|
state $runq = Parallel::Queue->can( 'runqueue' ); |
75
|
|
|
|
|
|
|
|
76
|
500
|
|
|
|
|
1241
|
$parent_pid = $$; |
77
|
|
|
|
|
|
|
|
78
|
500
|
|
|
|
|
793
|
my $qmgr = shift; |
79
|
500
|
|
|
|
|
893
|
my $jobs = shift; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# note that the queue may already be loaded |
82
|
|
|
|
|
|
|
# from construction or previous assignment. |
83
|
|
|
|
|
|
|
|
84
|
500
|
100
|
|
|
|
1557
|
$qmgr->queue = [ @_ ] |
85
|
|
|
|
|
|
|
if @_; |
86
|
|
|
|
|
|
|
|
87
|
500
|
|
|
|
|
1791
|
$runq->( $jobs, $qmgr ); |
88
|
422
|
|
|
|
|
1834
|
$qmgr |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub next_job |
92
|
|
|
|
|
|
|
{ |
93
|
|
|
|
|
|
|
# pull the item off the stack in the |
94
|
|
|
|
|
|
|
# parent process, not the child. ignore |
95
|
|
|
|
|
|
|
# $@, eval returning undef is sufficient |
96
|
|
|
|
|
|
|
# to end queue execution. |
97
|
|
|
|
|
|
|
|
98
|
2762
|
|
|
2762
|
0
|
6073
|
my $qmgr = shift; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
eval |
101
|
2762
|
|
|
|
|
8865
|
{ |
102
|
2762
|
|
|
|
|
10449
|
my $next = $qmgr->next; |
103
|
1654
|
|
|
1654
|
|
4209
|
sub { $qmgr->handler->( $next ) } |
104
|
2345
|
|
|
|
|
24589
|
} |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
######################################################################## |
108
|
|
|
|
|
|
|
# object manglement |
109
|
|
|
|
|
|
|
######################################################################## |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub new |
112
|
|
|
|
|
|
|
{ |
113
|
503
|
|
|
503
|
0
|
952380
|
my $qmgr = &construct; |
114
|
|
|
|
|
|
|
|
115
|
503
|
|
|
|
|
5064
|
$qmgr->EVERY::LAST::initialize( @_ ); |
116
|
503
|
|
|
|
|
1879
|
$qmgr |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub construct |
120
|
|
|
|
|
|
|
{ |
121
|
503
|
|
|
503
|
0
|
1217
|
my $proto = shift; |
122
|
|
|
|
|
|
|
|
123
|
503
|
|
33
|
|
|
3592
|
bless [], blessed $proto || $proto; |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub initialize |
127
|
|
|
|
|
|
|
{ |
128
|
503
|
|
|
503
|
0
|
30733
|
my $qmgr = shift; |
129
|
|
|
|
|
|
|
|
130
|
503
|
100
|
|
|
|
2443
|
$qmgr->handler = shift if @_; |
131
|
503
|
100
|
|
|
|
2587
|
$qmgr->queue = [ @_ ] if @_; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
return |
134
|
503
|
|
|
|
|
1161
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
DESTROY |
137
|
|
|
|
|
|
|
{ |
138
|
424
|
|
|
424
|
|
340932
|
my $qmgr = shift; |
139
|
|
|
|
|
|
|
|
140
|
424
|
|
|
|
|
5964
|
$qmgr->EVERY::cleanup; |
141
|
|
|
|
|
|
|
|
142
|
424
|
|
|
|
|
1784
|
undef @$qmgr; |
143
|
424
|
|
|
|
|
852
|
undef $qmgr; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
return |
146
|
424
|
|
|
|
|
4136
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub cleanup |
149
|
|
|
|
|
|
|
{ |
150
|
424
|
100
|
|
424
|
0
|
33795
|
if( $$ == $parent_pid ) |
151
|
|
|
|
|
|
|
{ |
152
|
420
|
|
|
|
|
892
|
my $qmgr = shift; |
153
|
420
|
|
|
|
|
959
|
my $queue = $qmgr->queue; |
154
|
|
|
|
|
|
|
|
155
|
420
|
100
|
|
|
|
1410
|
say STDERR join "\n\t", "($$) Incomplete jobs:", @$queue |
156
|
|
|
|
|
|
|
if @$queue; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
else |
159
|
|
|
|
|
|
|
{ |
160
|
|
|
|
|
|
|
# child running individual job has nothing to |
161
|
|
|
|
|
|
|
# clean up. |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
return |
165
|
424
|
|
|
|
|
795
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
# keep require happy |
168
|
|
|
|
|
|
|
1 |
169
|
|
|
|
|
|
|
__END__ |