Events/AsyncListener.pm

filter: Statementstmt 58.3% 7 / 12 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 40.0% 2 / 5 Podpod 100% 2 / 2 totaltotal 52.3% 11 / 21 CC 2 SCAR 11.0
CC
2
Cov
50%
async
6.0
handle
2.0
__ANON__
2.0
CRAP 3.0
« Events/Listeners.pm ↑ Summary Events/Listeners/Say.pm »
1 package Mojolicious::Plugin::Events::AsyncListener;
2 1 ▶use Mojo::Base 'Mojolicious::Plugin::Events::Listener';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 1 ▶use Mojo::IOLoop;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 =head2 handle
7  
8 Handle event
9  
10 =cut
11  
12 0 ▶sub handle {
Subroutine handle: not called CC=1 SCAR=6.9
Pod documented
13 0 return shift->async(@_);
14 }
15  
16 =head2 async
17  
18 Handle the event async
19  
20 =cut
21  
22 0 ▶sub async {
Subroutine async: not called CC=2 SCAR=17.9
Pod documented
23 0 my ($self, $data) = @_;
24
25 0 ▶ Mojo::IOLoop->timer(0 => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
26 0 return $self->handler($data);
27 0 });
28  
29 # When running from a command, ioloop is not running
30 # so we need to start it
31 0 ▶ Mojo::IOLoop->start if (!Mojo::IOLoop->is_running);
Branch: 1 branch
BranchTrueFalseTotal
if not "Mojo::IOLoop"->is_running 0 0 0
32 }
33  
34 1 1;
« Events/Listeners.pm ↑ Summary Events/Listeners/Say.pm »