| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Proc::JobQueue::DependencyTask; |
|
3
|
|
|
|
|
|
|
|
|
4
|
3
|
|
|
3
|
|
17
|
use strict; |
|
|
3
|
|
|
|
|
3
|
|
|
|
3
|
|
|
|
|
97
|
|
|
5
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
84
|
|
|
6
|
3
|
|
|
3
|
|
24
|
use Callback; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
160
|
|
|
7
|
3
|
|
|
3
|
|
16
|
use Scalar::Util qw(blessed); |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
154
|
|
|
8
|
3
|
|
|
3
|
|
15
|
use Carp qw(confess); |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
1489
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new |
|
11
|
|
|
|
|
|
|
{ |
|
12
|
7
|
|
|
7
|
0
|
140
|
my ($pkg, %params) = @_; |
|
13
|
7
|
|
|
|
|
112
|
my ($cpkg, $file, $line) = caller; |
|
14
|
7
|
50
|
|
|
|
21
|
confess "A function is required" unless $params{func}; |
|
15
|
7
|
|
50
|
|
|
111
|
$params{args} ||= []; |
|
16
|
|
|
|
|
|
|
my $task = bless { |
|
17
|
|
|
|
|
|
|
desc => $params{desc} || "no desc, called from $file:$line", |
|
18
|
|
|
|
|
|
|
trace => "$file:$line", |
|
19
|
0
|
|
|
0
|
|
0
|
errors => $params{errors} || sub { print STDERR @_ }, |
|
20
|
7
|
|
33
|
|
|
269
|
%params, |
|
|
|
|
50
|
|
|
|
|
|
21
|
|
|
|
|
|
|
}, $pkg; |
|
22
|
7
|
|
|
|
|
28
|
$task->set_cb($params{func}, $params{args}); |
|
23
|
7
|
|
|
|
|
356
|
return $task; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub set_cb |
|
27
|
|
|
|
|
|
|
{ |
|
28
|
7
|
|
|
7
|
0
|
11
|
my ($task, $func, $args) = @_; |
|
29
|
|
|
|
|
|
|
|
|
30
|
7
|
50
|
33
|
|
|
26
|
if (blessed($func) && $func->isa('Callback')) { |
|
31
|
0
|
|
|
|
|
0
|
$task->{cb} = $func; |
|
32
|
|
|
|
|
|
|
} else { |
|
33
|
7
|
|
|
|
|
83
|
$task->{cb} = Callback->new($func, @$args); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub run_dependency_task |
|
38
|
|
|
|
|
|
|
{ |
|
39
|
7
|
|
|
7
|
0
|
20
|
my ($task, $dependency_graph) = @_; |
|
40
|
|
|
|
|
|
|
|
|
41
|
7
|
|
|
|
|
13
|
my ($code, @more); |
|
42
|
7
|
|
|
|
|
9
|
eval { |
|
43
|
7
|
|
|
|
|
69
|
($code, @more) = $task->{cb}->call($task, $dependency_graph); |
|
44
|
|
|
|
|
|
|
}; |
|
45
|
7
|
50
|
|
|
|
1154
|
if ($@) { |
|
46
|
0
|
|
|
|
|
0
|
$task->{errors}->("----------------------- FAILURE\nTask $task->{desc} failed: $@\n"); |
|
47
|
0
|
|
|
|
|
0
|
$dependency_graph->stuck_dependency($task, "call failed: $@"); |
|
48
|
0
|
|
|
|
|
0
|
return 0; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
7
|
50
|
0
|
|
|
23
|
if ($code eq 'done') { |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
52
|
7
|
|
|
|
|
31
|
$dependency_graph->remove_dependency($task); |
|
53
|
7
|
|
|
|
|
372
|
return 1; |
|
54
|
|
|
|
|
|
|
} elsif ($code eq 'keep' || $code eq 'ignore') { |
|
55
|
|
|
|
|
|
|
# nada |
|
56
|
|
|
|
|
|
|
} elsif ($code eq 'requeue') { |
|
57
|
0
|
0
|
|
|
|
|
$task->set_cb(@more) if @more; |
|
58
|
0
|
|
|
|
|
|
$dependency_graph->unlock($task); |
|
59
|
|
|
|
|
|
|
} else { |
|
60
|
0
|
|
|
|
|
|
die "bad return code from $task->{desc}"; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
0
|
|
|
|
|
|
return 0; |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
__END__ |