line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Queue::Q::NaiveFIFO::Perl; |
2
|
3
|
|
|
3
|
|
185733
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
83
|
|
3
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
85
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
15
|
use Carp qw(croak); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
150
|
|
6
|
3
|
|
|
3
|
|
1119
|
use Queue::Q::NaiveFIFO; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
87
|
|
7
|
3
|
|
|
3
|
|
1521
|
use parent 'Queue::Q::NaiveFIFO'; |
|
3
|
|
|
|
|
626
|
|
|
3
|
|
|
|
|
21
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
6
|
|
|
6
|
1
|
35
|
my $class = shift; |
11
|
6
|
|
|
|
|
21
|
my $self = bless { |
12
|
|
|
|
|
|
|
@_, |
13
|
|
|
|
|
|
|
queue => [], |
14
|
|
|
|
|
|
|
} => $class; |
15
|
6
|
|
|
|
|
21
|
return $self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub enqueue_item { |
19
|
116
|
|
|
116
|
1
|
157
|
my $self = shift; |
20
|
116
|
|
|
|
|
127
|
push @{$self->{queue}}, shift; |
|
116
|
|
|
|
|
500
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub enqueue_items { |
24
|
4
|
|
|
4
|
1
|
7
|
my $self = shift; |
25
|
4
|
|
|
|
|
7
|
push @{$self->{queue}}, @_; |
|
4
|
|
|
|
|
21
|
|
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub claim_item { |
29
|
64
|
|
|
64
|
1
|
85
|
my $self = shift; |
30
|
64
|
|
|
|
|
79
|
return shift @{$self->{queue}}; |
|
64
|
|
|
|
|
185
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub claim_items { |
34
|
12
|
|
|
12
|
1
|
20
|
my $self = shift; |
35
|
12
|
|
100
|
|
|
35
|
my $n = shift || 1; |
36
|
12
|
|
|
|
|
19
|
my $q = $self->{queue}; |
37
|
12
|
|
|
|
|
20
|
my @items = splice(@{$self->{queue}}, 0, $n); |
|
12
|
|
|
|
|
34
|
|
38
|
12
|
|
|
|
|
41
|
return @items; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub flush_queue { |
42
|
12
|
|
|
12
|
1
|
1669
|
my $self = shift; |
43
|
12
|
|
|
|
|
18
|
@{ $self->{queue} } = (); |
|
12
|
|
|
|
|
52
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub queue_length { |
47
|
60
|
|
|
60
|
1
|
3920
|
my $self = shift; |
48
|
60
|
|
|
|
|
68
|
return scalar(@{ $self->{queue} }); |
|
60
|
|
|
|
|
194
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |