Webqq/Message/Queue.pm

filter: Statementstmt 5.5% 1 / 18 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 3 totaltotal 3.4% 1 / 29 CC 3 SCAR 15.4
CC
3
Cov
5%
put
6.0
get
6.0
new
2.0
CRAP 4.7
« Webqq/Client/Method/_cookie_proxy.pm ↑ Summary Plack/App/Openqq/SendGroupMessage.pm »
1 package Webqq::Message::Queue;
2 0 ▶sub new{
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
3 0 my $class = shift;
4 0 my $self = {
5 queue => [],
6 callback_for_get => undef,
7 callback_for_get_bak => undef,
8 };
9 0 return bless $self,$class;
10 }
11  
12 0 ▶sub put{
Subroutine put: not called CC=2 SCAR=17.9
Pod undocumented
13 0 my $self = shift;
14 die "Webqq::Message::Queue->put()失败,请检查是否已经设置了队列get()回调\n"
15 0 ▶ unless ref $self->{callback_for_get} eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self->{"callback_for_get"} eq "CODE" 0 0 0
16 0 push @{ $self->{queue} } ,$_[0];
17 0 $self->_notify_to_get();
18 }
19 0 ▶sub get{
Subroutine get: not called CC=2 SCAR=17.9
Pod undocumented
20 0 my $self = shift;
21 0 my $cb = shift;
22 0 ▶ die "Webqq::Message::Queue->get()仅接受一个函数引用\n" unless ref $cb eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cb eq "CODE" 0 0 0
23 0 $self->{callback_for_get} = $cb;
24 0 $self->{callback_for_get_bak} = $cb;
25 }
26 0 ▶sub _notify_to_get{
Subroutine _notify_to_get: not called CC=1 SCAR=6.9
27 0 my $self = shift;
28 0 my $msg = shift @{$self->{queue}};
29 0 $self->{callback_for_get}->($msg);
30 }
31  
32 1 1;
« Webqq/Client/Method/_cookie_proxy.pm ↑ Summary Plack/App/Openqq/SendGroupMessage.pm »