| 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
Condition33%1/3
@_ == 1 and ref $_[0] eq "HASH"
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"
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||