line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Queue::Q::NaiveFIFO::Perl; |
2
|
3
|
|
|
3
|
|
187706
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
74
|
|
3
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
78
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
15
|
use Carp qw(croak); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
153
|
|
6
|
3
|
|
|
3
|
|
1025
|
use Queue::Q::NaiveFIFO; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
88
|
|
7
|
3
|
|
|
3
|
|
1428
|
use parent 'Queue::Q::NaiveFIFO'; |
|
3
|
|
|
|
|
682
|
|
|
3
|
|
|
|
|
20
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
6
|
|
|
6
|
1
|
32
|
my $class = shift; |
11
|
6
|
|
|
|
|
20
|
my $self = bless { |
12
|
|
|
|
|
|
|
@_, |
13
|
|
|
|
|
|
|
queue => [], |
14
|
|
|
|
|
|
|
} => $class; |
15
|
6
|
|
|
|
|
20
|
return $self; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub enqueue_item { |
19
|
116
|
|
|
116
|
1
|
184
|
my $self = shift; |
20
|
116
|
|
|
|
|
154
|
push @{$self->{queue}}, shift; |
|
116
|
|
|
|
|
637
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub enqueue_items { |
24
|
4
|
|
|
4
|
1
|
10
|
my $self = shift; |
25
|
4
|
|
|
|
|
7
|
push @{$self->{queue}}, @_; |
|
4
|
|
|
|
|
23
|
|
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub claim_item { |
29
|
64
|
|
|
64
|
1
|
112
|
my $self = shift; |
30
|
64
|
|
|
|
|
87
|
return shift @{$self->{queue}}; |
|
64
|
|
|
|
|
216
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub claim_items { |
34
|
12
|
|
|
12
|
1
|
25
|
my $self = shift; |
35
|
12
|
|
100
|
|
|
33
|
my $n = shift || 1; |
36
|
12
|
|
|
|
|
28
|
my $q = $self->{queue}; |
37
|
12
|
|
|
|
|
18
|
my @items = splice(@{$self->{queue}}, 0, $n); |
|
12
|
|
|
|
|
39
|
|
38
|
12
|
|
|
|
|
46
|
return @items; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub flush_queue { |
42
|
12
|
|
|
12
|
1
|
1637
|
my $self = shift; |
43
|
12
|
|
|
|
|
18
|
@{ $self->{queue} } = (); |
|
12
|
|
|
|
|
53
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub queue_length { |
47
|
60
|
|
|
60
|
1
|
3972
|
my $self = shift; |
48
|
60
|
|
|
|
|
68
|
return scalar(@{ $self->{queue} }); |
|
60
|
|
|
|
|
215
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |