line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Hook::Fork::Task; |
2
|
7
|
|
|
7
|
|
22583
|
use strict; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
378
|
|
3
|
7
|
|
|
7
|
|
34
|
use warnings; |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
1503
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# note: we are not worried about memory cycles because the root lives |
6
|
|
|
|
|
|
|
# as long as the program, and any removed nodes have all references |
7
|
|
|
|
|
|
|
# removed. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
225
|
|
|
225
|
0
|
270
|
my ($class, $code) = @_; |
11
|
225
|
|
|
|
|
285
|
my $self = {}; |
12
|
225
|
|
|
|
|
386
|
$self->{code} = $code; |
13
|
225
|
|
|
|
|
311
|
$self->{next} = undef; |
14
|
225
|
|
|
|
|
250
|
$self->{prev} = undef; |
15
|
225
|
|
|
|
|
615
|
return bless $self, $class; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub run { |
19
|
16
|
|
|
16
|
0
|
94
|
my $self = shift; |
20
|
16
|
|
|
|
|
859
|
$self->{code}->(); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub remove { |
24
|
205
|
|
|
205
|
0
|
1342
|
my $self = shift; |
25
|
205
|
|
|
|
|
291
|
$self->{prev}{next} = $self->{next}; |
26
|
205
|
|
|
|
|
254
|
$self->{next}{prev} = $self->{prev}; |
27
|
205
|
|
|
|
|
259
|
$self->{next} = undef; |
28
|
205
|
|
|
|
|
1267
|
$self->{prev} = undef; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub append { |
32
|
210
|
|
|
210
|
0
|
223
|
my ($self, $next) = @_; |
33
|
210
|
|
|
|
|
241
|
$self->{next} = $next; |
34
|
210
|
|
|
|
|
361
|
$next->{prev} = $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |