blib/lib/IO/SocketAlarm.pm

filter: Statementstmt 96.8% 31 / 32 Branchbran 50.0% 1 / 2 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 10 / 10 Podpod 100% 3 / 3 totaltotal 88.4% 46 / 52 CC 3 SCAR 5.0
CC
3
Cov
89%
new
3.6
BEGIN
1.0
BEGIN
1.0
CRAP 1.6
« blib/lib/IO/SocketAlarm/Util.pm ↑ Summary pollfd_rbhash.c »
1 package IO::SocketAlarm;
2 6 $IO::SocketAlarm::VERSION = '0.003';
3 # VERSION
4 # ABSTRACT: Perform asynchronous actions when a socket changes status
5  
6 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 6 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 6 require XSLoader;
11 6 XSLoader::load('IO::SocketAlarm', $IO::SocketAlarm::VERSION);
12  
13 # All exports are part of the Util sub-package.
14 {package IO::SocketAlarm::Util;
15 6 $IO::SocketAlarm::Util::VERSION = '0.003';
16 6 our @EXPORT_OK= qw( socketalarm get_fd_table_str is_socket );
17 6 ▶ use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
18 # Declared in XS
19 }
20  
21 6 ▶sub import {
Subroutine import: called CC=1 SCAR=0.0
22 6 splice(@_, 0, 1, 'IO::SocketAlarm::Util');
23 6 goto \&IO::SocketAlarm::Util::import;
24 }
25  
26  
27 14 ▶sub new {
Subroutine new: called CC=3 SCAR=12.7
Pod documented
28 14 my $class= shift;
29 0 ▶ my %attrs= @_ == 1 && ref $_[0] eq 'HASH'? %{$_[0]} : @_;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 && ref $_[0] eq 'HASH' ? : 0 14 14
Condition33%1/3
@_ == 1 and ref $_[0] eq "HASH"
!ll&&!rl&&r
1400
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1 ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
30 14 my $self= bless \%attrs, $class;
31 14 $self->_init_socketalarm(@attrs{'socket','events','actions'});
32 }
33  
34  
35 2 ▶sub triggered { $_[0]->cur_action >= 0 }
Subroutine triggered: called CC=1 SCAR=0.0
Pod documented
36 1 ▶sub finished { $_[0]->cur_action >= $_[0]->action_count }
Subroutine finished: called CC=1 SCAR=0.0
Pod documented
37  
38  
39 # Before global destruction, de-activate the alarms and ask the watcher thread to terminate.
40 # This way bizarre things don't happen when global destruction starts calling destructors
41 # in the wrong order.
42 6 ▶END { _terminate_all() }
Subroutine END: called CC=1 SCAR=0.0
43  
44 6 1;
45  
46 __END__
« blib/lib/IO/SocketAlarm/Util.pm ↑ Summary pollfd_rbhash.c »