RabbitMQ/LocalQueue.pm

filter: Statementstmt 81.0% 30 / 37 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 3 totaltotal 74.5% 38 / 51 CC 4 SCAR 9.6
CC
4
Cov
78%
_flush
6.0
_drain_queue
3.0
BEGIN
1.0
CRAP 2.6
« RabbitMQ.pm ↑ Summary
1 package AnyEvent::RabbitMQ::LocalQueue;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 our $VERSION = '1.22'; # VERSION
7  
8 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
9 1 my $class = shift;
10 1 return bless {
11 _message_queue => [],
12 _drain_code_queue => [],
13 }, $class;
14 }
15  
16 6 ▶sub push {
Subroutine push: called CC=1 SCAR=0.0
Pod undocumented
17 6 my $self = shift;
18  
19 6 CORE::push @{$self->{_message_queue}}, @_;
20 6 return $self->_drain_queue();
21 }
22  
23 6 ▶sub get {
Subroutine get: called CC=1 SCAR=0.0
Pod undocumented
24 6 my $self = shift;
25  
26 6 CORE::push @{$self->{_drain_code_queue}}, @_;
27 6 return $self->_drain_queue();
28 }
29  
30 12 ▶sub _drain_queue {
Subroutine _drain_queue: called CC=3 SCAR=11.0
31 12 my $self = shift;
32  
33 12 my $message_count = scalar @{$self->{_message_queue}};
34 12 my $drain_code_count = scalar @{$self->{_drain_code_queue}};
35  
36 12 ▶ my $count = $message_count < $drain_code_count
Branch: 1 branch
BranchTrueFalseTotal
$message_count < $drain_code_count ? : 4 8 12
37 ? $message_count : $drain_code_count;
38  
39 12 for (1 .. $count) {
40 10 &{shift @{$self->{_drain_code_queue}}}(
41 10 shift @{$self->{_message_queue}}
42 );
43 }
44  
45 12 return $self;
46 }
47  
48 0 ▶sub _flush {
Subroutine _flush: not called CC=2 SCAR=17.9
49 0 my ($self, $frame) = @_;
50  
51 0 $self->_drain_queue;
52  
53 0 ▶ while (my $cb = shift @{$self->{_drain_code_queue}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $cb = shift @{$$self{"_drain_code_queue"};}) 0 0 0
54 0 local $@; # Flush frames immediately, throwing away errors for on-close
55 0 eval { $cb->($frame) };
56 }
57 }
58  
59 2 1;
60  
« RabbitMQ.pm ↑ Summary