line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Cassandra::Client::Policy::Queue::Default; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TVDW'; |
3
|
|
|
|
|
|
|
$Cassandra::Client::Policy::Queue::Default::VERSION = '0.13_004'; # TRIAL |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
15
|
$Cassandra::Client::Policy::Queue::Default::VERSION = '0.13004';use 5.010; |
|
1
|
|
|
|
|
3
|
|
6
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
16
|
|
7
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
171
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
0
|
|
|
0
|
0
|
|
my ($class, %args)= @_; |
11
|
|
|
|
|
|
|
|
12
|
0
|
|
0
|
|
|
|
my $max_entries= $args{max_entries} || 0; # Default: never overflow |
13
|
|
|
|
|
|
|
|
14
|
0
|
|
|
|
|
|
return bless { |
15
|
|
|
|
|
|
|
max_entries => 0+ $max_entries, |
16
|
|
|
|
|
|
|
has_any => 0, # We're using this as a count. |
17
|
|
|
|
|
|
|
queue => [], |
18
|
|
|
|
|
|
|
}, $class; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub enqueue { |
22
|
0
|
|
|
0
|
0
|
|
my ($self, $item)= @_; |
23
|
|
|
|
|
|
|
|
24
|
0
|
0
|
0
|
|
|
|
if ($self->{max_entries} && $self->{has_any} >= $self->{max_entries}) { |
25
|
0
|
|
|
|
|
|
return "command queue full: $self->{has_any} entries"; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
push @{$self->{queue}}, $item; |
|
0
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
$self->{has_any}++; |
30
|
0
|
|
|
|
|
|
return; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub dequeue { |
34
|
0
|
|
|
0
|
0
|
|
my ($self)= @_; |
35
|
0
|
|
|
|
|
|
my $item= shift @{$self->{queue}}; |
|
0
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
$self->{has_any}= 0+@{$self->{queue}}; |
|
0
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
return $item; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |