line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package NgxQueue::PP; |
2
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use Scalar::Util; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
158
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
8
|
1
|
|
|
1
|
0
|
33
|
my ($class, $data) = @_; |
9
|
1
|
|
|
|
|
4
|
my $self = bless {data => $data}, $class; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
|
|
7
|
$self->prev($self); |
12
|
1
|
|
|
|
|
8
|
$self->next($self); |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
|
|
3
|
$self; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
0
|
|
|
0
|
0
|
0
|
sub data { shift->{data} } |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
for my $accessor (qw/next prev/) { |
20
|
1
|
|
|
1
|
|
6
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
54
|
|
21
|
|
|
|
|
|
|
*{__PACKAGE__."::$accessor"} = sub { |
22
|
1
|
|
|
1
|
|
5
|
use strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
584
|
|
23
|
2
|
|
|
2
|
|
3
|
my ($self, $arg) = @_; |
24
|
2
|
50
|
|
|
|
12
|
if ($arg) { |
25
|
2
|
|
|
|
|
4
|
$self->{$accessor} = $arg; |
26
|
2
|
50
|
|
|
|
17
|
Scalar::Util::weaken($self->{$accessor}) if $self eq $arg; |
27
|
|
|
|
|
|
|
} |
28
|
2
|
|
|
|
|
5
|
$self->{$accessor}; |
29
|
|
|
|
|
|
|
}; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub empty { |
33
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
34
|
0
|
|
|
|
|
|
$self->prev eq $self; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub insert_head { |
38
|
0
|
|
|
0
|
0
|
|
my ($self, $queue) = @_; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
$queue->next($self->next); |
41
|
0
|
|
|
|
|
|
$queue->next->prev($queue); |
42
|
0
|
|
|
|
|
|
$queue->prev($self); |
43
|
0
|
|
|
|
|
|
$self->next($queue); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
*insert_after = \&insert_head; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub insert_tail { |
48
|
0
|
|
|
0
|
0
|
|
my ($self, $queue) = @_; |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
$queue->prev($self->prev); |
51
|
0
|
|
|
|
|
|
$queue->prev->next($queue); |
52
|
0
|
|
|
|
|
|
$queue->next($self); |
53
|
0
|
|
|
|
|
|
$self->prev($queue); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub head { |
57
|
0
|
|
|
0
|
0
|
|
shift->next; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub last { |
61
|
0
|
|
|
0
|
0
|
|
shift->prev; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub remove { |
65
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
$self->next->prev($self->prev); |
68
|
0
|
|
|
|
|
|
$self->prev->next($self->next); |
69
|
0
|
|
|
|
|
|
$self->next(undef); |
70
|
0
|
|
|
|
|
|
$self->prev(undef); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub split { |
74
|
0
|
|
|
0
|
0
|
|
my ($self, $splitter, $new) = @_; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
$new->prev($self->prev); |
77
|
0
|
|
|
|
|
|
$new->prev->next($new); |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
$new->next($splitter); |
80
|
0
|
|
|
|
|
|
$self->prev($splitter->prev); |
81
|
0
|
|
|
|
|
|
$self->prev->next($self); |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
$splitter->prev($new); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub add { |
87
|
0
|
|
|
0
|
0
|
|
my ($self, $queue) = @_; |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
$self->prev->next($queue->next); |
90
|
0
|
|
|
|
|
|
$queue->next->prev($self->prev); |
91
|
0
|
|
|
|
|
|
$self->prev($queue->prev); |
92
|
0
|
|
|
|
|
|
$self->prev->next($self); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub foreach { |
96
|
0
|
|
|
0
|
0
|
|
my ($self, $cb) = @_; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
0
|
|
|
|
for (my $q = $self->head; $q ne $self && !$self->empty; $q = $q->next) { |
99
|
0
|
|
|
|
|
|
local $_ = $q; |
100
|
0
|
|
|
|
|
|
$cb->(); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
__END__ |