| 1 | 32 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 32 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | package AnyEvent::Proc; | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | # ABSTRACT: Run external commands | ||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 32 | ▶ | use AnyEvent; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 32 | ▶ | use AnyEvent::Handle; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 32 | ▶ | use AnyEvent::Util (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 32 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 32 | ▶ | use Class::Load; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 32 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 32 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 32 | ▶ | use POSIX; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 32 | our $VERSION = '0.105'; # VERSION | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 32 | our @EXPORT_OK = qw(run run_cb reader writer); | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 78 | ▶ | sub _rpipe { | ||||||||||||||||||||||||||
|
Subroutine
_rpipe: called CC=1 SCAR=2.0
| |||||||||||||||||||||||||||||
| 22 | 78 | my ( $R, $W ) = AnyEvent::Util::portable_pipe; | |||||||||||||||||||||||||||
| 23 | ( | ||||||||||||||||||||||||||||
| 24 | $R, | ||||||||||||||||||||||||||||
| 25 | AnyEvent::Handle->new( | ||||||||||||||||||||||||||||
| 26 | fh => $W, | ||||||||||||||||||||||||||||
| 27 | 0 | ▶ | on_error => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 28 | 0 | my ( $handle, $fatal, $message ) = @_; | |||||||||||||||||||||||||||
| 29 | 0 | AE::log warn => "error writing to handle: $message"; | |||||||||||||||||||||||||||
| 30 | 0 | $handle->destroy; | |||||||||||||||||||||||||||
| 31 | }, | ||||||||||||||||||||||||||||
| 32 | 78 | ), | |||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 150 | ▶ | sub _wpipe { | ||||||||||||||||||||||||||
|
Subroutine
_wpipe: called CC=1 SCAR=3.1
| |||||||||||||||||||||||||||||
| 37 | 150 | my ( $R, $W ) = AnyEvent::Util::portable_pipe; | |||||||||||||||||||||||||||
| 38 | ( | ||||||||||||||||||||||||||||
| 39 | AnyEvent::Handle->new( | ||||||||||||||||||||||||||||
| 40 | fh => $R, | ||||||||||||||||||||||||||||
| 41 | 0 | ▶ | on_error => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 42 | 0 | my ( $handle, $fatal, $message ) = @_; | |||||||||||||||||||||||||||
| 43 | 0 | ▶ | AE::log warn => "error reading from handle: $message" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | unless $message =~ m{unexpected end-of-file}i; | ||||||||||||||||||||||||||||
| 45 | 0 | $handle->destroy; | |||||||||||||||||||||||||||
| 46 | }, | ||||||||||||||||||||||||||||
| 47 | 150 | ), | |||||||||||||||||||||||||||
| 48 | $W, | ||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 59 | ▶ | sub _on_read_helper { | ||||||||||||||||||||||||||
|
Subroutine
_on_read_helper: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 53 | 59 | my ( $aeh, $sub ) = @_; | |||||||||||||||||||||||||||
| 54 | $aeh->on_read( | ||||||||||||||||||||||||||||
| 55 | 36 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 56 | 36 | my $x = $_[0]->rbuf; | |||||||||||||||||||||||||||
| 57 | 36 | $_[0]->rbuf = ''; | |||||||||||||||||||||||||||
| 58 | 36 | $sub->($x); | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | 59 | ); | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 1 | ▶ | sub _read_on_scalar { | ||||||||||||||||||||||||||
|
Subroutine
_read_on_scalar: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 64 | 1 | my ( $var, $sub ) = @_; | |||||||||||||||||||||||||||
| 65 | 1 | ▶ | my $old = $$var || ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
$$var || ''
MC/DC0%0/1
$$var || ''
$$var
Truth table50%1/2
A
A= $$var
| |||||||||||||||||||||||||||||
| 66 | 1 | tie $$var, __PACKAGE__ . '::TiedScalar', $sub; | |||||||||||||||||||||||||||
| 67 | 1 | $$var = $old; | |||||||||||||||||||||||||||
| 68 | 1 | $var; | |||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | sub _reaper { | ||||||||||||||||||||||||||
|
Subroutine
_reaper: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 72 | 0 | my ( $self, $waiters ) = @_; | |||||||||||||||||||||||||||
| 73 | 0 | ▶ | my $sub = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | # my $message = shift; # currently unused | ||||||||||||||||||||||||||||
| 76 | 0 | foreach my $waiter (@$waiters) { | |||||||||||||||||||||||||||
| 77 | 0 | AE::log debug => "reap $waiter"; | |||||||||||||||||||||||||||
| 78 | 0 | ▶ | if ( ref $waiter eq 'CODE' ) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 79 | 0 | $waiter->(undef); | |||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | elsif ( ref $waiter eq 'AnyEvent::CondVar' ) { | ||||||||||||||||||||||||||||
| 82 | 0 | $waiter->send(undef); | |||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | elsif ( ref $waiter eq 'Coro::Channel' ) { | ||||||||||||||||||||||||||||
| 85 | 0 | $waiter->shutdown; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | else { | ||||||||||||||||||||||||||||
| 88 | 0 | AE::log note => "cannot reap $waiter"; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | 0 | }; | |||||||||||||||||||||||||||
| 92 | 0 | push @{ $self->{reapers} } => $sub; | |||||||||||||||||||||||||||
| 93 | 0 | $sub; | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 0 | ▶ | sub _push_waiter { | ||||||||||||||||||||||||||
|
Subroutine
_push_waiter: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 97 | 0 | my ( $self, $what, $var ) = @_; | |||||||||||||||||||||||||||
| 98 | 0 | push @{ $self->{waiters}->{$what} } => $var; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 69 | ▶ | sub _run_cmd { | ||||||||||||||||||||||||||
|
Subroutine
_run_cmd: called CC=8 SCAR=21.0
| |||||||||||||||||||||||||||||
| 102 | 69 | my ( $cmd, $redir, $pidref ) = @_; | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 69 | my $cv = AE::cv; | |||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 69 | my %redir = %$redir; | |||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 69 | my $pid = fork; | |||||||||||||||||||||||||||
| 109 | 69 | ▶ | AE::log error => "cannot fork: $!" unless defined $pid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 69 | ▶ | unless ($pid) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | # move any existing fd's out of the way | ||||||||||||||||||||||||||||
| 114 | # this also ensures that dup2 is never called with fd1==fd2 | ||||||||||||||||||||||||||||
| 115 | # so the cloexec flag is always cleared | ||||||||||||||||||||||||||||
| 116 | 22 | my ( @oldfh, @close ); | |||||||||||||||||||||||||||
| 117 | 22 | for my $fh ( values %redir ) { | |||||||||||||||||||||||||||
| 118 | 68 | push @oldfh, $fh; # make sure we keep it open | |||||||||||||||||||||||||||
| 119 | 68 | $fh = fileno $fh; # we only want the fd | |||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | # dup if we are in the way | ||||||||||||||||||||||||||||
| 122 | # if we "leak" fds here, they will be dup2'ed over later | ||||||||||||||||||||||||||||
| 123 | defined( $fh = POSIX::dup($fh) ) | ||||||||||||||||||||||||||||
| 124 | or POSIX::_exit(124) | ||||||||||||||||||||||||||||
| 125 | 68 | ▶ | while exists $redir{$fh}; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | # execute redirects | ||||||||||||||||||||||||||||
| 129 | 22 | ▶ | while ( my ( $k, $v ) = each %redir ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | 68 | ▶ | defined POSIX::dup2( $v, $k ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | or POSIX::_exit(123); | ||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 22 | AnyEvent::Util::close_all_fds_except( keys %redir ); | |||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 22 | my $bin = $cmd->[0]; | |||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 32 | ▶ | no warnings; ## no critic | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 22 | exec {$bin} @$cmd; | |||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 0 | POSIX::_exit(126); | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 47 | $$pidref = $pid; | |||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 47 | my $w; | |||||||||||||||||||||||||||
| 148 | 47 | ▶ | $w = AE::child $pid => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 149 | 47 | my $status = $_[1] >> 8; | |||||||||||||||||||||||||||
| 150 | 47 | my $signal = $_[1] & 127; | |||||||||||||||||||||||||||
| 151 | 47 | my $coredump = $_[1] & 128; | |||||||||||||||||||||||||||
| 152 | 47 | ▶ | AE::log info => "child exited with status $status" if $status; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 153 | 47 | ▶ | AE::log debug => "child exited with signal $signal" if $signal; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 154 | 47 | ▶ | AE::log note => "child exited with coredump" if $coredump; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 155 | 47 | undef $w; | |||||||||||||||||||||||||||
| 156 | 47 | map { close $_ } values %redir; | |||||||||||||||||||||||||||
| 157 | 47 | $cv->send($status); | |||||||||||||||||||||||||||
| 158 | 47 | }; | |||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 47 | $cv; | |||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 69 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=17 SCAR=28.6
Pod
documented
| |||||||||||||||||||||||||||||
| 164 | 69 | my ( $class, %options ) = @_; | |||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 69 | ▶ | $options{args} ||= []; | ||||||||||||||||||||||||||
|
Condition100%2/2
$options{"args"} ||= []
MC/DC100%1/1
$options{"args"} ||= []
$options{"args"}
Truth table100%2/2
A
A= $options{"args"}
| |||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 69 | my ( $rIN, $wIN ) = _rpipe; | |||||||||||||||||||||||||||
| 169 | 69 | my ( $rOUT, $wOUT ) = _wpipe; | |||||||||||||||||||||||||||
| 170 | 69 | my ( $rERR, $wERR ) = _wpipe; | |||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 69 | ▶ | my @xhs = @{ delete( $options{extras} ) || [] }; | ||||||||||||||||||||||||||
|
Condition100%2/2
delete $options{'extras'} || []
MC/DC100%1/1
delete $options{'extras'} || []
delete $options{'extras'}
Truth table100%2/2
A
A= delete $options{'extras'}
| |||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 69 | my @args = map { "$_" } @{ delete $options{args} }; | |||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | 69 | my $pid; | |||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | my %redir = ( | ||||||||||||||||||||||||||||
| 179 | 0 => $rIN, | ||||||||||||||||||||||||||||
| 180 | 1 => $wOUT, | ||||||||||||||||||||||||||||
| 181 | 2 => $wERR, | ||||||||||||||||||||||||||||
| 182 | 69 | map { ( "$_" => $_->B ) } @xhs | |||||||||||||||||||||||||||
| 183 | ); | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 69 | my $cv = _run_cmd( [ delete $options{bin} => @args ], \%redir, \$pid ); | |||||||||||||||||||||||||||
| 186 | 47 | my $waiter = AE::cv; | |||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | my $self = bless { | ||||||||||||||||||||||||||||
| 189 | handles => { | ||||||||||||||||||||||||||||
| 190 | in => $wIN, | ||||||||||||||||||||||||||||
| 191 | out => $rOUT, | ||||||||||||||||||||||||||||
| 192 | err => $rERR, | ||||||||||||||||||||||||||||
| 193 | 3 | map { ( "$_" => $_->A ) } @xhs, | |||||||||||||||||||||||||||
| 194 | }, | ||||||||||||||||||||||||||||
| 195 | pid => $pid, | ||||||||||||||||||||||||||||
| 196 | listeners => { | ||||||||||||||||||||||||||||
| 197 | exit => delete $options{on_exit}, | ||||||||||||||||||||||||||||
| 198 | ttl_exceed => delete $options{on_ttl_exceed}, | ||||||||||||||||||||||||||||
| 199 | }, | ||||||||||||||||||||||||||||
| 200 | eol => "\n", | ||||||||||||||||||||||||||||
| 201 | cv => $cv, | ||||||||||||||||||||||||||||
| 202 | alive => 1, | ||||||||||||||||||||||||||||
| 203 | waiter => $waiter, | ||||||||||||||||||||||||||||
| 204 | waiters => { | ||||||||||||||||||||||||||||
| 205 | in => [], | ||||||||||||||||||||||||||||
| 206 | out => [], | ||||||||||||||||||||||||||||
| 207 | err => [], | ||||||||||||||||||||||||||||
| 208 | 47 | ▶ | map { ( "$_" => [] ) } @xhs | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||
| 209 | }, | ||||||||||||||||||||||||||||
| 210 | reapers => [], | ||||||||||||||||||||||||||||
| 211 | } => ref $class | ||||||||||||||||||||||||||||
| 212 | || $class; | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 47 | map { $_->{proc} = $self } @xhs; | |||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | { | ||||||||||||||||||||||||||||
| 217 | 47 | my $eol = quotemeta $self->_eol; | |||||||||||||||||||||||||||
| 218 | 47 | ▶ | $self->{reol} = delete $options{reol} || qr{$eol}; | ||||||||||||||||||||||||||
|
Condition50%1/2
delete $options{'reol'} || qr/$eol/
MC/DC0%0/1
delete $options{'reol'} || qr/$eol/
delete $options{'reol'}
Truth table50%1/2
A
A= delete $options{'reol'}
| |||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 47 | ▶ | if ( $options{ttl} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 222 | $self->{timer} = AnyEvent->timer( | ||||||||||||||||||||||||||||
| 223 | after => delete $options{ttl}, | ||||||||||||||||||||||||||||
| 224 | 17 | ▶ | cb => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||
| 225 | 17 | ▶ | return unless $self->alive; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | 17 | $self->kill; | |||||||||||||||||||||||||||
| 227 | 17 | $self->_emit('ttl_exceed'); | |||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||
| 229 | 37 | ); | |||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||
| 232 | 47 | ▶ | my $kill = sub { $self->end }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 47 | ▶ | if ( $options{timeout} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 235 | 4 | $wIN->timeout( $options{timeout} ); | |||||||||||||||||||||||||||
| 236 | 4 | $rOUT->timeout( $options{timeout} ); | |||||||||||||||||||||||||||
| 237 | 4 | $rERR->timeout( $options{timeout} ); | |||||||||||||||||||||||||||
| 238 | 4 | delete $options{timeout}; | |||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | 4 | ▶ | $self->_on( timeout => ( delete( $options{on_timeout} ) || $kill ) ); | ||||||||||||||||||||||||||
|
Condition33%1/3
delete $options{'on_timeout'} || $kill
MC/DC0%0/2
delete $options{'on_timeout'} || $kill
delete $options{'on_timeout'}
$kill
Truth table33%1/3
A || B
A= delete $options{'on_timeout'}B= $kill
| |||||||||||||||||||||||||||||
| 241 | 4 | ▶ | my $cb = sub { $self->_emit('timeout') }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 242 | 4 | $wIN->on_timeout($cb); | |||||||||||||||||||||||||||
| 243 | 4 | $rOUT->on_timeout($cb); | |||||||||||||||||||||||||||
| 244 | 4 | $rERR->on_timeout($cb); | |||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | 47 | ▶ | if ( $options{wtimeout} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 248 | 3 | $wIN->wtimeout( delete $options{wtimeout} ); | |||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | 3 | ▶ | $self->_on( wtimeout => ( delete( $options{on_wtimeout} ) || $kill ) ); | ||||||||||||||||||||||||||
|
Condition33%1/3
delete $options{'on_wtimeout'} || $kill
MC/DC0%0/2
delete $options{'on_wtimeout'} || $kill
delete $options{'on_wtimeout'}
$kill
Truth table33%1/3
A || B
A= delete $options{'on_wtimeout'}B= $kill
| |||||||||||||||||||||||||||||
| 251 | 3 | ▶ | my $cb = sub { $self->_emit('wtimeout') }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 252 | 3 | $wIN->on_wtimeout($cb); | |||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | 47 | ▶ | if ( $options{rtimeout} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 256 | 2 | $rOUT->rtimeout( delete $options{rtimeout} ); | |||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 2 | ▶ | $self->_on( rtimeout => ( delete( $options{on_rtimeout} ) || $kill ) ); | ||||||||||||||||||||||||||
|
Condition33%1/3
delete $options{'on_rtimeout'} || $kill
MC/DC0%0/2
delete $options{'on_rtimeout'} || $kill
delete $options{'on_rtimeout'}
$kill
Truth table33%1/3
A || B
A= delete $options{'on_rtimeout'}B= $kill
| |||||||||||||||||||||||||||||
| 259 | 2 | ▶ | my $cb = sub { $self->_emit('rtimeout') }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 260 | 2 | $rOUT->on_rtimeout($cb); | |||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 47 | ▶ | if ( $options{etimeout} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 264 | 1 | $rERR->rtimeout( delete $options{etimeout} ); | |||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | 1 | ▶ | $self->_on( etimeout => ( delete( $options{on_etimeout} ) || $kill ) ); | ||||||||||||||||||||||||||
|
Condition33%1/3
delete $options{'on_etimeout'} || $kill
MC/DC0%0/2
delete $options{'on_etimeout'} || $kill
delete $options{'on_etimeout'}
$kill
Truth table33%1/3
A || B
A= delete $options{'on_etimeout'}B= $kill
| |||||||||||||||||||||||||||||
| 267 | 1 | ▶ | my $cb = sub { $self->_emit('etimeout') }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 268 | 1 | $rERR->on_rtimeout($cb); | |||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | 47 | ▶ | if ( $options{errstr} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 272 | 16 | my $sref = delete $options{errstr}; | |||||||||||||||||||||||||||
| 273 | 16 | $$sref = ''; | |||||||||||||||||||||||||||
| 274 | 16 | $self->pipe( err => $sref ); | |||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | 47 | ▶ | if ( $options{outstr} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 278 | 26 | my $sref = delete $options{outstr}; | |||||||||||||||||||||||||||
| 279 | 26 | $$sref = ''; | |||||||||||||||||||||||||||
| 280 | 26 | $self->pipe( out => $sref ); | |||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | 47 | $waiter->begin; | |||||||||||||||||||||||||||
| 284 | $cv->cb( | ||||||||||||||||||||||||||||
| 285 | 47 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 286 | 47 | $self->{status} = shift->recv; | |||||||||||||||||||||||||||
| 287 | 47 | $self->{alive} = 0; | |||||||||||||||||||||||||||
| 288 | 47 | undef $self->{timer}; | |||||||||||||||||||||||||||
| 289 | 47 | $waiter->end; | |||||||||||||||||||||||||||
| 290 | 47 | $self->_emit( exit => $self->{status} ); | |||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||
| 292 | 47 | ); | |||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | 47 | ▶ | if ( keys %options ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 295 | 0 | AE::log note => "unknown left-over option(s): " . join ', ' => | |||||||||||||||||||||||||||
| 296 | keys %options; | ||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | 47 | $self; | |||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | 3 | ▶ | sub reader { | ||||||||||||||||||||||||||
|
Subroutine
reader: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 303 | 3 | my ( $r, $w ) = _wpipe; | |||||||||||||||||||||||||||
| 304 | 3 | bless { | |||||||||||||||||||||||||||
| 305 | r => $r, | ||||||||||||||||||||||||||||
| 306 | w => $w, | ||||||||||||||||||||||||||||
| 307 | fileno => fileno( $r->fh ) | ||||||||||||||||||||||||||||
| 308 | } => __PACKAGE__ | ||||||||||||||||||||||||||||
| 309 | . '::R'; | ||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | 2 | ▶ | sub writer { | ||||||||||||||||||||||||||
|
Subroutine
writer: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 313 | 2 | my ( $r, $w ) = _rpipe; | |||||||||||||||||||||||||||
| 314 | 2 | bless { | |||||||||||||||||||||||||||
| 315 | r => $r, | ||||||||||||||||||||||||||||
| 316 | w => $w, | ||||||||||||||||||||||||||||
| 317 | fileno => fileno( $w->fh ) | ||||||||||||||||||||||||||||
| 318 | } => __PACKAGE__ | ||||||||||||||||||||||||||||
| 319 | . '::W'; | ||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | 12 | ▶ | sub run { | ||||||||||||||||||||||||||
|
Subroutine
run: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 323 | 12 | my $cv = AE::cv; | |||||||||||||||||||||||||||
| 324 | run_cb( | ||||||||||||||||||||||||||||
| 325 | @_, | ||||||||||||||||||||||||||||
| 326 | 9 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 327 | 9 | $cv->send( \@_ ); | |||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||
| 329 | 12 | )->recv; | |||||||||||||||||||||||||||
| 330 | 9 | my ( $out, $err, $status ) = @{ $cv->recv }; | |||||||||||||||||||||||||||
| 331 | 9 | $? = $status << 8; | |||||||||||||||||||||||||||
| 332 | 9 | ▶ | if (wantarray) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 333 | 3 | return ( $out, $err ); | |||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||
| 335 | else { | ||||||||||||||||||||||||||||
| 336 | 6 | ▶ | carp $err if $err; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 337 | 6 | return $out; | |||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | 14 | ▶ | sub run_cb { | ||||||||||||||||||||||||||
|
Subroutine
run_cb: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 342 | 14 | my $bin = shift; | |||||||||||||||||||||||||||
| 343 | 14 | my $cb = pop; | |||||||||||||||||||||||||||
| 344 | 14 | my @args = @_; | |||||||||||||||||||||||||||
| 345 | 14 | my ( $out, $err ) = ( '', '' ); | |||||||||||||||||||||||||||
| 346 | 14 | my $proc = __PACKAGE__->new( | |||||||||||||||||||||||||||
| 347 | bin => $bin, | ||||||||||||||||||||||||||||
| 348 | args => \@args, | ||||||||||||||||||||||||||||
| 349 | outstr => \$out, | ||||||||||||||||||||||||||||
| 350 | errstr => \$err | ||||||||||||||||||||||||||||
| 351 | ); | ||||||||||||||||||||||||||||
| 352 | 10 | $proc->finish; | |||||||||||||||||||||||||||
| 353 | $proc->wait( | ||||||||||||||||||||||||||||
| 354 | 10 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 355 | 10 | my $status = $proc->{status}; | |||||||||||||||||||||||||||
| 356 | 10 | $? = $status << 8; | |||||||||||||||||||||||||||
| 357 | 10 | $cb->( $out, $err, $status ); | |||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||
| 359 | 10 | ); | |||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | 10 | ▶ | sub _on { | ||||||||||||||||||||||||||
|
Subroutine
_on: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 363 | 10 | my ( $self, $name, $handler ) = @_; | |||||||||||||||||||||||||||
| 364 | 10 | $self->{listeners}->{$name} = $handler; | |||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | 35 | ▶ | sub in { shift->_geth('in') } | ||||||||||||||||||||||||||
|
Subroutine
in: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | 0 | ▶ | sub out { shift->_geth('out') } | ||||||||||||||||||||||||||
|
Subroutine
out: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | 0 | ▶ | sub err { shift->_geth('err') } | ||||||||||||||||||||||||||
|
Subroutine
err: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | 105 | ▶ | sub _geth { | ||||||||||||||||||||||||||
|
Subroutine
_geth: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 374 | 105 | shift->{handles}->{ pop() }; | |||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | 56 | ▶ | sub _eol { shift->{eol} } | ||||||||||||||||||||||||||
|
Subroutine
_eol: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 378 | 0 | ▶ | sub _reol { shift->{reol} } | ||||||||||||||||||||||||||
|
Subroutine
_reol: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | 74 | ▶ | sub _emit { | ||||||||||||||||||||||||||
|
Subroutine
_emit: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 381 | 74 | my ( $self, $name, @args ) = @_; | |||||||||||||||||||||||||||
| 382 | 74 | AE::log debug => "trapped $name"; | |||||||||||||||||||||||||||
| 383 | 74 | ▶ | if ( exists $self->{listeners}->{$name} | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $self->{"listeners"}{$name} and defined $self->{"listeners"}{$name}
MC/DC50%1/2
exists $self->{"listeners"}{$name} and defined $self->{"listeners"}{$name}
exists $self->{"listeners"}{$name}
defined $self->{"listeners"}{$name}
Truth table66%2/3
A and B
A= exists $self->{"listeners"}{$name}B= defined $self->{"listeners"}{$name}
| |||||||||||||||||||||||||||||
| 384 | and defined $self->{listeners}->{$name} ) | ||||||||||||||||||||||||||||
| 385 | { | ||||||||||||||||||||||||||||
| 386 | 25 | $self->{listeners}->{$name}->( $self, @args ); | |||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | 35 | ▶ | sub pid { | ||||||||||||||||||||||||||
|
Subroutine
pid: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 391 | 35 | shift->{pid}; | |||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | 35 | ▶ | sub fire { | ||||||||||||||||||||||||||
|
Subroutine
fire: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 395 | 35 | my ( $self, $signal ) = @_; | |||||||||||||||||||||||||||
| 396 | 35 | ▶ | $signal = 'TERM' unless defined $signal; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 397 | 35 | $signal =~ s{^sig}{}i; | |||||||||||||||||||||||||||
| 398 | 35 | AE::log debug => "fire SIG$signal"; | |||||||||||||||||||||||||||
| 399 | 35 | kill uc $signal => $self->pid; | |||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | 17 | ▶ | sub kill { | ||||||||||||||||||||||||||
|
Subroutine
kill: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 403 | 17 | my ($self) = @_; | |||||||||||||||||||||||||||
| 404 | 17 | $self->fire('kill'); | |||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | 0 | ▶ | sub fire_and_kill { | ||||||||||||||||||||||||||
|
Subroutine
fire_and_kill: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 408 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 409 | 0 | ▶ | my $cb = ( ref $_[-1] eq 'CODE' ? pop : undef ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 410 | 0 | my $time = pop; | |||||||||||||||||||||||||||
| 411 | 0 | ▶ | my $signal = uc( pop || 'TERM' ); | ||||||||||||||||||||||||||
|
Condition0%0/2
pop() || 'TERM'
MC/DC0%0/1
pop() || 'TERM'
pop()
Truth table0%0/2
A
A= pop()
| |||||||||||||||||||||||||||||
| 412 | my $w = AnyEvent->timer( | ||||||||||||||||||||||||||||
| 413 | after => $time, | ||||||||||||||||||||||||||||
| 414 | 0 | ▶ | cb => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 415 | 0 | ▶ | return unless $self->alive; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 416 | 0 | $self->kill; | |||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||
| 418 | 0 | ); | |||||||||||||||||||||||||||
| 419 | 0 | $self->fire($signal); | |||||||||||||||||||||||||||
| 420 | 0 | ▶ | if ($cb) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 421 | return $self->wait( | ||||||||||||||||||||||||||||
| 422 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 423 | 0 | undef $w; | |||||||||||||||||||||||||||
| 424 | 0 | $cb->(@_); | |||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||
| 426 | 0 | ); | |||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||
| 428 | else { | ||||||||||||||||||||||||||||
| 429 | 0 | my $exit = $self->wait; | |||||||||||||||||||||||||||
| 430 | 0 | undef $w; | |||||||||||||||||||||||||||
| 431 | 0 | return $exit; | |||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||
| 435 | 17 | ▶ | sub alive { | ||||||||||||||||||||||||||
|
Subroutine
alive: called CC=3 SCAR=11.7
Pod
documented
| |||||||||||||||||||||||||||||
| 436 | 17 | my $self = shift; | |||||||||||||||||||||||||||
| 437 | 17 | ▶ | return 0 unless $self->{alive}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 438 | 17 | ▶ | $self->fire(0) ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | 47 | ▶ | sub wait { | ||||||||||||||||||||||||||
|
Subroutine
wait: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 442 | 47 | my ( $self, $cb ) = @_; | |||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | 47 | ▶ | my $next = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 445 | 47 | my $cv = shift; | |||||||||||||||||||||||||||
| 446 | 47 | $cv->recv; | |||||||||||||||||||||||||||
| 447 | 47 | waitpid $self->{pid} => 0; | |||||||||||||||||||||||||||
| 448 | 47 | ▶ | $cb->( $self->{status} ) if ref $cb eq 'CODE'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 449 | 47 | $self->end; | |||||||||||||||||||||||||||
| 450 | 47 | $self->{status}; | |||||||||||||||||||||||||||
| 451 | 47 | }; | |||||||||||||||||||||||||||
| 452 | AE::log debug => "waiting for " | ||||||||||||||||||||||||||||
| 453 | 47 | . ( $self->{waiter}->{_ae_counter} ) . " ends"; | |||||||||||||||||||||||||||
| 454 | 47 | ▶ | if ($cb) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 455 | 11 | $self->{waiter}->cb($next); | |||||||||||||||||||||||||||
| 456 | 11 | return $self->{waiter}; | |||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||
| 458 | else { | ||||||||||||||||||||||||||||
| 459 | 36 | $self->{waiter}->recv; | |||||||||||||||||||||||||||
| 460 | 36 | return $next->( $self->{waiter} ); | |||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||
| 464 | 35 | ▶ | sub finish { | ||||||||||||||||||||||||||
|
Subroutine
finish: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 465 | 35 | my ($self) = @_; | |||||||||||||||||||||||||||
| 466 | 35 | $self->in->destroy; | |||||||||||||||||||||||||||
| 467 | 35 | $self; | |||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||
| 470 | 57 | ▶ | sub end { | ||||||||||||||||||||||||||
|
Subroutine
end: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 471 | 57 | my ($self) = @_; | |||||||||||||||||||||||||||
| 472 | 57 | map { $_->destroy } values %{ $self->{handles} }; | |||||||||||||||||||||||||||
| 473 | 0 | map { $_->() } @{ $self->{reapers} }; | |||||||||||||||||||||||||||
| 474 | 57 | $self; | |||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||
| 477 | 0 | ▶ | sub stop_timeout { | ||||||||||||||||||||||||||
|
Subroutine
stop_timeout: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 478 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 479 | 0 | $self->in->timeout(0); | |||||||||||||||||||||||||||
| 480 | 0 | $self->out->timeout(0); | |||||||||||||||||||||||||||
| 481 | 0 | $self->err->timeout(0); | |||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | 0 | ▶ | sub stop_wtimeout { | ||||||||||||||||||||||||||
|
Subroutine
stop_wtimeout: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 485 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 486 | 0 | $self->in->wtimeout(0); | |||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | 0 | ▶ | sub stop_rtimeout { | ||||||||||||||||||||||||||
|
Subroutine
stop_rtimeout: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 490 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 491 | 0 | $self->out->rtimeout(0); | |||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||
| 494 | 0 | ▶ | sub stop_etimeout { | ||||||||||||||||||||||||||
|
Subroutine
stop_etimeout: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 495 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 496 | 0 | $self->err->rtimeout(0); | |||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||
| 499 | 20 | ▶ | sub write { | ||||||||||||||||||||||||||
|
Subroutine
write: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 500 | 20 | my ( $self, $type, @args ) = @_; | |||||||||||||||||||||||||||
| 501 | 20 | my $ok = 0; | |||||||||||||||||||||||||||
| 502 | 20 | ▶ | try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 503 | 20 | $self->_geth('in')->push_write( $type => @args ); | |||||||||||||||||||||||||||
| 504 | 20 | $ok = 1; | |||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||
| 506 | 0 | ▶ | catch { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 507 | 0 | AE::log warn => $_; | |||||||||||||||||||||||||||
| 508 | 20 | }; | |||||||||||||||||||||||||||
| 509 | 20 | $ok; | |||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||
| 512 | 8 | ▶ | sub writeln { | ||||||||||||||||||||||||||
|
Subroutine
writeln: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 513 | 8 | my ( $self, @lines ) = @_; | |||||||||||||||||||||||||||
| 514 | 8 | $self->write( $_ . $self->_eol ) for @lines; | |||||||||||||||||||||||||||
| 515 | 8 | $self; | |||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||
| 518 | 50 | ▶ | sub pipe { | ||||||||||||||||||||||||||
|
Subroutine
pipe: called CC=12 SCAR=26.1
Pod
documented
| |||||||||||||||||||||||||||||
| 519 | 50 | my $self = shift; | |||||||||||||||||||||||||||
| 520 | 50 | my $peer = pop; | |||||||||||||||||||||||||||
| 521 | 50 | ▶ | my $what = ( pop || 'out' ); | ||||||||||||||||||||||||||
|
Condition100%2/2
pop() || 'out'
MC/DC100%1/1
pop() || 'out'
pop()
Truth table100%2/2
A
A= pop()
| |||||||||||||||||||||||||||||
| 522 | 50 | ▶ | if ( ref $what ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 523 | 2 | $what = "$what"; | |||||||||||||||||||||||||||
| 524 | } | ||||||||||||||||||||||||||||
| 525 | else { | ||||||||||||||||||||||||||||
| 526 | 48 | $what = lc $what; | |||||||||||||||||||||||||||
| 527 | 48 | $what =~ s{^std}{}; | |||||||||||||||||||||||||||
| 528 | } | ||||||||||||||||||||||||||||
| 529 | 32 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 530 | 50 | my $sub; | |||||||||||||||||||||||||||
| 531 | 50 | ▶ | if ( blessed $peer) { | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 532 | 3 | ▶ | if ( $peer->isa(__PACKAGE__) ) { | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 533 | 0 | ▶ | $sub = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 534 | 0 | $peer->write(shift); | |||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||
| 536 | 0 | } | |||||||||||||||||||||||||||
| 537 | elsif ( $peer->isa('AnyEvent::Handle') ) { | ||||||||||||||||||||||||||||
| 538 | 2 | ▶ | $sub = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 539 | 2 | $peer->push_write(shift); | |||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||
| 541 | 2 | } | |||||||||||||||||||||||||||
| 542 | elsif ( $peer->isa('Coro::Channel') ) { | ||||||||||||||||||||||||||||
| 543 | 0 | ▶ | $sub = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 544 | 0 | $peer->put(shift); | |||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||
| 546 | 0 | } | |||||||||||||||||||||||||||
| 547 | elsif ( $peer->can('print') ) { | ||||||||||||||||||||||||||||
| 548 | 1 | ▶ | $sub = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 549 | 1 | $peer->print(shift); | |||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||
| 551 | 1 | } | |||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||
| 553 | elsif ( ref $peer eq 'SCALAR' ) { | ||||||||||||||||||||||||||||
| 554 | 21 | ▶ | $sub = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 555 | 21 | $$peer .= shift; | |||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||
| 557 | 44 | } | |||||||||||||||||||||||||||
| 558 | elsif ( ref $peer eq 'GLOB' ) { | ||||||||||||||||||||||||||||
| 559 | 3 | ▶ | $sub = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 560 | 3 | print $peer shift(); | |||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||
| 562 | 3 | } | |||||||||||||||||||||||||||
| 563 | elsif ( ref $peer eq 'CODE' ) { | ||||||||||||||||||||||||||||
| 564 | 0 | $sub = $peer; | |||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||
| 566 | 50 | ▶ | if ($sub) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 567 | 50 | AE::log debug => "pipe $peer from $what"; | |||||||||||||||||||||||||||
| 568 | 50 | my $aeh = $self->_geth($what); | |||||||||||||||||||||||||||
| 569 | $aeh->on_eof( | ||||||||||||||||||||||||||||
| 570 | 50 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 571 | 50 | AE::log debug => "eof: $what"; | |||||||||||||||||||||||||||
| 572 | 50 | shift->destroy; | |||||||||||||||||||||||||||
| 573 | 50 | $self->{waiter}->end; | |||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||
| 575 | 50 | ); | |||||||||||||||||||||||||||
| 576 | 50 | $self->{output}->{$what} = _on_read_helper( $aeh, $sub ); | |||||||||||||||||||||||||||
| 577 | 50 | $self->{waiter}->begin; | |||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||
| 579 | else { | ||||||||||||||||||||||||||||
| 580 | 0 | AE::log fatal => "cannot pipe $peer from $what"; | |||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||
| 584 | 15 | ▶ | sub pull { | ||||||||||||||||||||||||||
|
Subroutine
pull: called CC=9 SCAR=26.6
Pod
documented
| |||||||||||||||||||||||||||||
| 585 | 15 | my ( $self, $peer ) = @_; | |||||||||||||||||||||||||||
| 586 | 15 | $self->{input} = $peer; | |||||||||||||||||||||||||||
| 587 | 15 | AE::log debug => "pull $peer to stdin"; | |||||||||||||||||||||||||||
| 588 | 32 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 589 | 15 | my $sub; | |||||||||||||||||||||||||||
| 590 | 15 | ▶ | if ( blessed $peer) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 591 | 11 | ▶ | if ( $peer->isa(__PACKAGE__) ) { | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 592 | 0 | return $peer->pipe($self); | |||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||
| 594 | elsif ( $peer->isa('AnyEvent::Handle') ) { | ||||||||||||||||||||||||||||
| 595 | $peer->on_eof( | ||||||||||||||||||||||||||||
| 596 | 9 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 597 | 9 | AE::log debug => "pull($peer)->on_eof"; | |||||||||||||||||||||||||||
| 598 | 9 | shift->destroy; | |||||||||||||||||||||||||||
| 599 | 9 | $self->finish; | |||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||
| 601 | 9 | ); | |||||||||||||||||||||||||||
| 602 | $peer->on_error( | ||||||||||||||||||||||||||||
| 603 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 604 | 0 | AE::log error => "pull($peer)->on_error(" . $_[2] . ")"; | |||||||||||||||||||||||||||
| 605 | 0 | shift->destroy; | |||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||
| 607 | 9 | ); | |||||||||||||||||||||||||||
| 608 | return _on_read_helper( | ||||||||||||||||||||||||||||
| 609 | $peer, | ||||||||||||||||||||||||||||
| 610 | 9 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 611 | 9 | AE::log debug => "pull($peer)->on_read"; | |||||||||||||||||||||||||||
| 612 | 9 | $self->write( shift() ); | |||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||
| 614 | 9 | ); | |||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||
| 616 | elsif ( $peer->isa('IO::Handle') ) { | ||||||||||||||||||||||||||||
| 617 | 2 | return $self->pull( AnyEvent::Handle->new( fh => $peer ) ); | |||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||
| 619 | elsif ( $peer->isa('Coro::Channel') ) { | ||||||||||||||||||||||||||||
| 620 | 0 | ▶ | if ( my $class = load_class('Coro') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 621 | return $class->new( | ||||||||||||||||||||||||||||
| 622 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 623 | 0 | ▶ | while ( my $x = $peer->get ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 624 | 0 | ▶ | $self->write($x) or last; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 625 | 0 | Coro::cede(); | |||||||||||||||||||||||||||
| 626 | } | ||||||||||||||||||||||||||||
| 627 | 0 | $self->finish; | |||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||
| 629 | 0 | ); | |||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||
| 633 | elsif ( ref $peer eq 'SCALAR' ) { | ||||||||||||||||||||||||||||
| 634 | return _read_on_scalar( | ||||||||||||||||||||||||||||
| 635 | $peer, | ||||||||||||||||||||||||||||
| 636 | 3 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 637 | 3 | AE::log debug => "pull($peer)->STORE"; | |||||||||||||||||||||||||||
| 638 | 3 | $self->write( shift() ); | |||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||
| 640 | 1 | ); | |||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||
| 642 | elsif ( ref $peer eq 'GLOB' ) { | ||||||||||||||||||||||||||||
| 643 | 3 | return $self->pull( AnyEvent::Handle->new( fh => $peer ) ); | |||||||||||||||||||||||||||
| 644 | } | ||||||||||||||||||||||||||||
| 645 | 0 | AE::log fatal => "cannot pull $peer to stdin"; | |||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||
| 648 | 0 | ▶ | sub _push_read { | ||||||||||||||||||||||||||
|
Subroutine
_push_read: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 649 | 0 | my ( $self, $what, @args ) = @_; | |||||||||||||||||||||||||||
| 650 | 0 | my $ok = 0; | |||||||||||||||||||||||||||
| 651 | 0 | ▶ | try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 652 | 0 | $self->_geth($what)->push_read(@args); | |||||||||||||||||||||||||||
| 653 | 0 | $ok = 1; | |||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||
| 655 | 0 | ▶ | catch { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 656 | 0 | AE::log note => "cannot push_read from std$what: $_"; | |||||||||||||||||||||||||||
| 657 | 0 | }; | |||||||||||||||||||||||||||
| 658 | 0 | $ok; | |||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||
| 661 | 0 | ▶ | sub _unshift_read { | ||||||||||||||||||||||||||
|
Subroutine
_unshift_read: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 662 | 0 | my ( $self, $what, @args ) = @_; | |||||||||||||||||||||||||||
| 663 | 0 | my $ok = 0; | |||||||||||||||||||||||||||
| 664 | 0 | ▶ | try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 665 | 0 | $self->_geth($what)->unshift_read(@args); | |||||||||||||||||||||||||||
| 666 | 0 | $ok = 1; | |||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||
| 668 | 0 | ▶ | catch { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 669 | 0 | AE::log note => "cannot unshift_read from std$what: $_"; | |||||||||||||||||||||||||||
| 670 | 0 | }; | |||||||||||||||||||||||||||
| 671 | 0 | $ok; | |||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||
| 674 | 0 | ▶ | sub _readline { | ||||||||||||||||||||||||||
|
Subroutine
_readline: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 675 | 0 | my ( $self, $what, $sub ) = @_; | |||||||||||||||||||||||||||
| 676 | 0 | $self->_push_read( $what => line => $self->_reol, $sub ); | |||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||
| 679 | 0 | ▶ | sub _readchunk { | ||||||||||||||||||||||||||
|
Subroutine
_readchunk: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 680 | 0 | my ( $self, $what, $bytes, $sub ) = @_; | |||||||||||||||||||||||||||
| 681 | 0 | $self->_push_read( $what => chunk => $bytes => $sub ); | |||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||
| 683 | |||||||||||||||||||||||||||||
| 684 | 0 | ▶ | sub _sub_cb { | ||||||||||||||||||||||||||
|
Subroutine
_sub_cb: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 685 | 0 | my ($cb) = @_; | |||||||||||||||||||||||||||
| 686 | 0 | ▶ | sub { $cb->( $_[1] ) } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 687 | 0 | } | |||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||
| 689 | 0 | ▶ | sub _sub_cv { | ||||||||||||||||||||||||||
|
Subroutine
_sub_cv: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 690 | 0 | my ($cv) = @_; | |||||||||||||||||||||||||||
| 691 | 0 | ▶ | sub { $cv->send( $_[1] ) } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 692 | 0 | } | |||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||
| 694 | 0 | ▶ | sub _sub_ch { | ||||||||||||||||||||||||||
|
Subroutine
_sub_ch: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 695 | 0 | my ($ch) = @_; | |||||||||||||||||||||||||||
| 696 | 0 | ▶ | sub { $ch->put( $_[1] ) } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 697 | 0 | } | |||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||
| 699 | 0 | ▶ | sub _readline_cb { | ||||||||||||||||||||||||||
|
Subroutine
_readline_cb: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 700 | 0 | my ( $self, $what, $cb ) = @_; | |||||||||||||||||||||||||||
| 701 | 0 | $self->_push_waiter( $what => $cb ); | |||||||||||||||||||||||||||
| 702 | 0 | $self->_readline( $what => _sub_cb($cb) ); | |||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||
| 705 | 0 | ▶ | sub _readline_cv { | ||||||||||||||||||||||||||
|
Subroutine
_readline_cv: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 706 | 0 | my ( $self, $what, $cv ) = @_; | |||||||||||||||||||||||||||
| 707 | 0 | ▶ | $cv ||= AE::cv; | ||||||||||||||||||||||||||
|
Condition0%0/3
$cv ||= &AE::cv()
MC/DC0%0/2
$cv ||= &AE::cv()
$cv
&AE::cv()
Truth table0%0/3
A ||= B
A= $cvB= &AE::cv()
| |||||||||||||||||||||||||||||
| 708 | 0 | $self->_push_waiter( $what => $cv ); | |||||||||||||||||||||||||||
| 709 | 0 | ▶ | $cv->send unless $self->_readline( $what => _sub_cv($cv) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 710 | 0 | $cv; | |||||||||||||||||||||||||||
| 711 | } | ||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||
| 713 | 0 | ▶ | sub _readline_ch { | ||||||||||||||||||||||||||
|
Subroutine
_readline_ch: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 714 | 0 | my ( $self, $what, $channel ) = @_; | |||||||||||||||||||||||||||
| 715 | 0 | ▶ | unless ($channel) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 716 | 0 | ▶ | if ( my $class = load_class('Coro::Channel') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 717 | 0 | ▶ | $channel ||= $class->new; | ||||||||||||||||||||||||||
|
Condition0%0/3
$channel ||= $class->new
MC/DC0%0/2
$channel ||= $class->new
$channel
$class->new
Truth table0%0/3
A ||= B
A= $channelB= $class->new
| |||||||||||||||||||||||||||||
| 718 | } | ||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||
| 720 | 0 | $self->_push_waiter( $what => $channel ); | |||||||||||||||||||||||||||
| 721 | 0 | ▶ | $channel->shutdown unless $self->_readline( $what => _sub_ch($channel) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 722 | 0 | $channel; | |||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||
| 725 | 0 | ▶ | sub _readlines_cb { | ||||||||||||||||||||||||||
|
Subroutine
_readlines_cb: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 726 | 0 | my ( $self, $what, $cb ) = @_; | |||||||||||||||||||||||||||
| 727 | 0 | $self->_push_waiter( $what => $cb ); | |||||||||||||||||||||||||||
| 728 | $self->_geth($what)->on_read( | ||||||||||||||||||||||||||||
| 729 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 730 | 0 | $self->_readline( $what => _sub_cb($cb) ); | |||||||||||||||||||||||||||
| 731 | } | ||||||||||||||||||||||||||||
| 732 | 0 | ); | |||||||||||||||||||||||||||
| 733 | } | ||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||
| 735 | 0 | ▶ | sub _readlines_ch { | ||||||||||||||||||||||||||
|
Subroutine
_readlines_ch: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 736 | 0 | my ( $self, $what, $channel ) = @_; | |||||||||||||||||||||||||||
| 737 | 0 | ▶ | unless ($channel) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 738 | 0 | ▶ | if ( my $class = load_class('Coro::Channel') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 739 | 0 | ▶ | $channel ||= $class->new; | ||||||||||||||||||||||||||
|
Condition0%0/3
$channel ||= $class->new
MC/DC0%0/2
$channel ||= $class->new
$channel
$class->new
Truth table0%0/3
A ||= B
A= $channelB= $class->new
| |||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||
| 741 | } | ||||||||||||||||||||||||||||
| 742 | 0 | $self->_push_waiter( $what => $channel ); | |||||||||||||||||||||||||||
| 743 | $channel->shutdown unless $self->_geth($what)->on_read( | ||||||||||||||||||||||||||||
| 744 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 745 | 0 | $self->_readline( $what => _sub_ch($channel) ); | |||||||||||||||||||||||||||
| 746 | } | ||||||||||||||||||||||||||||
| 747 | 0 | ▶ | ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 748 | 0 | $channel; | |||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||
| 751 | 0 | ▶ | sub _readchunk_cb { | ||||||||||||||||||||||||||
|
Subroutine
_readchunk_cb: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 752 | 0 | my ( $self, $what, $bytes, $cb ) = @_; | |||||||||||||||||||||||||||
| 753 | 0 | $self->_push_waiter( $what => $cb ); | |||||||||||||||||||||||||||
| 754 | 0 | $self->_readchunk( $what, $bytes, _sub_cb($cb) ); | |||||||||||||||||||||||||||
| 755 | } | ||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||
| 757 | 0 | ▶ | sub _readchunk_cv { | ||||||||||||||||||||||||||
|
Subroutine
_readchunk_cv: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 758 | 0 | my ( $self, $what, $bytes, $cv ) = @_; | |||||||||||||||||||||||||||
| 759 | 0 | ▶ | $cv ||= AE::cv; | ||||||||||||||||||||||||||
|
Condition0%0/3
$cv ||= &AE::cv()
MC/DC0%0/2
$cv ||= &AE::cv()
$cv
&AE::cv()
Truth table0%0/3
A ||= B
A= $cvB= &AE::cv()
| |||||||||||||||||||||||||||||
| 760 | 0 | $self->_push_waiter( $what => $cv ); | |||||||||||||||||||||||||||
| 761 | 0 | $self->_readchunk( $what, $bytes, _sub_cv($cv) ); | |||||||||||||||||||||||||||
| 762 | 0 | $cv; | |||||||||||||||||||||||||||
| 763 | } | ||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||
| 765 | 0 | ▶ | sub _readchunk_ch { | ||||||||||||||||||||||||||
|
Subroutine
_readchunk_ch: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 766 | 0 | my ( $self, $what, $bytes, $channel ) = @_; | |||||||||||||||||||||||||||
| 767 | 0 | ▶ | unless ($channel) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 768 | 0 | ▶ | if ( my $class = load_class('Coro::Channel') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 769 | 0 | ▶ | $channel ||= $class->new; | ||||||||||||||||||||||||||
|
Condition0%0/3
$channel ||= $class->new
MC/DC0%0/2
$channel ||= $class->new
$channel
$class->new
Truth table0%0/3
A ||= B
A= $channelB= $class->new
| |||||||||||||||||||||||||||||
| 770 | } | ||||||||||||||||||||||||||||
| 771 | } | ||||||||||||||||||||||||||||
| 772 | 0 | $self->_push_waiter( $what => $channel ); | |||||||||||||||||||||||||||
| 773 | 0 | ▶ | $channel->shutdown unless $self->_readline( $what => _sub_ch($channel) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 774 | 0 | $channel; | |||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||
| 777 | 0 | ▶ | sub _readchunks_ch { | ||||||||||||||||||||||||||
|
Subroutine
_readchunks_ch: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 778 | 0 | my ( $self, $what, $bytes, $channel ) = @_; | |||||||||||||||||||||||||||
| 779 | 0 | ▶ | unless ($channel) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 780 | 0 | ▶ | if ( my $class = load_class('Coro::Channel') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 781 | 0 | ▶ | $channel ||= $class->new; | ||||||||||||||||||||||||||
|
Condition0%0/3
$channel ||= $class->new
MC/DC0%0/2
$channel ||= $class->new
$channel
$class->new
Truth table0%0/3
A ||= B
A= $channelB= $class->new
| |||||||||||||||||||||||||||||
| 782 | } | ||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||
| 784 | 0 | $self->_push_waiter( $what => $channel ); | |||||||||||||||||||||||||||
| 785 | $channel->shutdown unless $self->_geth($what)->on_read( | ||||||||||||||||||||||||||||
| 786 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 787 | 0 | $self->_readline( $what => _sub_ch($channel) ); | |||||||||||||||||||||||||||
| 788 | } | ||||||||||||||||||||||||||||
| 789 | 0 | ▶ | ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 790 | 0 | $channel; | |||||||||||||||||||||||||||
| 791 | } | ||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||
| 793 | 0 | ▶ | sub readline_cb { | ||||||||||||||||||||||||||
|
Subroutine
readline_cb: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 794 | 0 | my ( $self, $cb ) = @_; | |||||||||||||||||||||||||||
| 795 | 0 | $self->_readline_cb( out => $cb ); | |||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||
| 798 | 0 | ▶ | sub readline_cv { | ||||||||||||||||||||||||||
|
Subroutine
readline_cv: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 799 | 0 | my ( $self, $cv ) = @_; | |||||||||||||||||||||||||||
| 800 | 0 | $self->_readline_cv( out => $cv ); | |||||||||||||||||||||||||||
| 801 | } | ||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||
| 803 | 0 | ▶ | sub readline_ch { | ||||||||||||||||||||||||||
|
Subroutine
readline_ch: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 804 | 0 | my ( $self, $ch ) = @_; | |||||||||||||||||||||||||||
| 805 | 0 | $self->_readline_ch( out => $ch ); | |||||||||||||||||||||||||||
| 806 | } | ||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||
| 808 | 0 | ▶ | sub readlines_cb { | ||||||||||||||||||||||||||
|
Subroutine
readlines_cb: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 809 | 0 | my ( $self, $cb ) = @_; | |||||||||||||||||||||||||||
| 810 | 0 | $self->_readlines_cb( out => $cb ); | |||||||||||||||||||||||||||
| 811 | } | ||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||
| 813 | 0 | ▶ | sub readlines_ch { | ||||||||||||||||||||||||||
|
Subroutine
readlines_ch: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 814 | 0 | my ( $self, $ch ) = @_; | |||||||||||||||||||||||||||
| 815 | 0 | $self->_readlines_ch( out => $ch ); | |||||||||||||||||||||||||||
| 816 | } | ||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||
| 818 | 0 | ▶ | sub readline { | ||||||||||||||||||||||||||
|
Subroutine
readline: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 819 | 0 | shift->readline_cv->recv; | |||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||
| 822 | 0 | ▶ | sub readline_error_cb { | ||||||||||||||||||||||||||
|
Subroutine
readline_error_cb: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 823 | 0 | my ( $self, $cb ) = @_; | |||||||||||||||||||||||||||
| 824 | 0 | $self->_readline_cb( err => $cb ); | |||||||||||||||||||||||||||
| 825 | } | ||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||
| 827 | 0 | ▶ | sub readline_error_cv { | ||||||||||||||||||||||||||
|
Subroutine
readline_error_cv: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 828 | 0 | my ( $self, $cv ) = @_; | |||||||||||||||||||||||||||
| 829 | 0 | $self->_readline_cv( err => $cv ); | |||||||||||||||||||||||||||
| 830 | } | ||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||
| 832 | 0 | ▶ | sub readline_error_ch { | ||||||||||||||||||||||||||
|
Subroutine
readline_error_ch: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 833 | 0 | my ( $self, $ch ) = @_; | |||||||||||||||||||||||||||
| 834 | 0 | $self->_readline_ch( err => $ch ); | |||||||||||||||||||||||||||
| 835 | } | ||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||
| 837 | 0 | ▶ | sub readlines_error_cb { | ||||||||||||||||||||||||||
|
Subroutine
readlines_error_cb: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 838 | 0 | my ( $self, $cb ) = @_; | |||||||||||||||||||||||||||
| 839 | 0 | $self->_readlines_cb( out => $cb ); | |||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||
| 842 | 0 | ▶ | sub readlines_error_ch { | ||||||||||||||||||||||||||
|
Subroutine
readlines_error_ch: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 843 | 0 | my ( $self, $ch ) = @_; | |||||||||||||||||||||||||||
| 844 | 0 | $self->_readlines_ch( out => $ch ); | |||||||||||||||||||||||||||
| 845 | } | ||||||||||||||||||||||||||||
| 846 | |||||||||||||||||||||||||||||
| 847 | 0 | ▶ | sub readline_error { | ||||||||||||||||||||||||||
|
Subroutine
readline_error: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 848 | 0 | shift->readline_error_cv->recv; | |||||||||||||||||||||||||||
| 849 | } | ||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||
| 851 | # AnyEvent::Impl::Perl has some issues with POSIX::dup. | ||||||||||||||||||||||||||||
| 852 | # This statement solves the problem. | ||||||||||||||||||||||||||||
| 853 | 31 | ▶ | AnyEvent::post_detect { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 854 | 31 | ▶ | AE::child $$ => sub { }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 855 | 32 | }; | |||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||
| 857 | 32 | 1; | |||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||
| 859 | package # hidden | ||||||||||||||||||||||||||||
| 860 | AnyEvent::Proc::R; | ||||||||||||||||||||||||||||
| 861 | |||||||||||||||||||||||||||||
| 862 | 32 | ▶ | use overload '""' => sub { shift->{fileno} }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 863 | |||||||||||||||||||||||||||||
| 864 | 2 | ▶ | sub A { shift->{r} } | ||||||||||||||||||||||||||
|
Subroutine
A: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 865 | 3 | ▶ | sub B { shift->{w} } | ||||||||||||||||||||||||||
|
Subroutine
B: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 866 | |||||||||||||||||||||||||||||
| 867 | 0 | ▶ | sub on_timeout { | ||||||||||||||||||||||||||
|
Subroutine
on_timeout: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 868 | 0 | shift->A->on_wtimeout(pop); | |||||||||||||||||||||||||||
| 869 | } | ||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||
| 871 | 0 | ▶ | sub stop_timeout { | ||||||||||||||||||||||||||
|
Subroutine
stop_timeout: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 872 | 0 | shift->A->stop_wtimeout; | |||||||||||||||||||||||||||
| 873 | } | ||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||
| 875 | 2 | ▶ | sub pipe { | ||||||||||||||||||||||||||
|
Subroutine
pipe: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 876 | 2 | my ( $self, $peer ) = @_; | |||||||||||||||||||||||||||
| 877 | 2 | $self->{proc}->pipe( $self => $peer ); | |||||||||||||||||||||||||||
| 878 | } | ||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||
| 880 | 0 | ▶ | sub readline_cb { | ||||||||||||||||||||||||||
|
Subroutine
readline_cb: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 881 | 0 | my ( $self, $cb ) = @_; | |||||||||||||||||||||||||||
| 882 | 0 | $self->{proc}->_readline_cb( $self => $cb ); | |||||||||||||||||||||||||||
| 883 | } | ||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||
| 885 | 0 | ▶ | sub readline_cv { | ||||||||||||||||||||||||||
|
Subroutine
readline_cv: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 886 | 0 | my ( $self, $cv ) = @_; | |||||||||||||||||||||||||||
| 887 | 0 | $self->{proc}->_readline_cv( $self => $cv ); | |||||||||||||||||||||||||||
| 888 | } | ||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||
| 890 | 0 | ▶ | sub readline_ch { | ||||||||||||||||||||||||||
|
Subroutine
readline_ch: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 891 | 0 | my ( $self, $ch ) = @_; | |||||||||||||||||||||||||||
| 892 | 0 | $self->{proc}->_readline_ch( $self => $ch ); | |||||||||||||||||||||||||||
| 893 | } | ||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||
| 895 | 0 | ▶ | sub readlines_cb { | ||||||||||||||||||||||||||
|
Subroutine
readlines_cb: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 896 | 0 | my ( $self, $cb ) = @_; | |||||||||||||||||||||||||||
| 897 | 0 | $self->{proc}->_readlines_cb( $self => $cb ); | |||||||||||||||||||||||||||
| 898 | } | ||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||
| 900 | 0 | ▶ | sub readlines_ch { | ||||||||||||||||||||||||||
|
Subroutine
readlines_ch: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 901 | 0 | my ( $self, $ch ) = @_; | |||||||||||||||||||||||||||
| 902 | 0 | $self->{proc}->_readlines_cb( $self => $ch ); | |||||||||||||||||||||||||||
| 903 | } | ||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||
| 905 | 0 | ▶ | sub readline { | ||||||||||||||||||||||||||
|
Subroutine
readline: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 906 | 0 | shift->readline_cv->recv; | |||||||||||||||||||||||||||
| 907 | } | ||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||
| 909 | 32 | 1; | |||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||
| 911 | package # hidden | ||||||||||||||||||||||||||||
| 912 | AnyEvent::Proc::W; | ||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||
| 914 | 32 | ▶ | use overload '""' => sub { shift->{fileno} }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||
| 916 | 32 | ▶ | use Try::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||
| 918 | 3 | ▶ | sub A { shift->{w} } | ||||||||||||||||||||||||||
|
Subroutine
A: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 919 | 2 | ▶ | sub B { shift->{r} } | ||||||||||||||||||||||||||
|
Subroutine
B: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||
| 921 | 1 | ▶ | sub finish { | ||||||||||||||||||||||||||
|
Subroutine
finish: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 922 | 1 | shift->A->destroy; | |||||||||||||||||||||||||||
| 923 | } | ||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||
| 925 | 0 | ▶ | sub on_timeout { | ||||||||||||||||||||||||||
|
Subroutine
on_timeout: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 926 | 0 | shift->A->on_rtimeout(pop); | |||||||||||||||||||||||||||
| 927 | } | ||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||
| 929 | 0 | ▶ | sub stop_timeout { | ||||||||||||||||||||||||||
|
Subroutine
stop_timeout: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 930 | 0 | shift->A->stop_rtimeout; | |||||||||||||||||||||||||||
| 931 | } | ||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||
| 933 | 1 | ▶ | sub write { | ||||||||||||||||||||||||||
|
Subroutine
write: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 934 | 1 | my ( $self, $type, @args ) = @_; | |||||||||||||||||||||||||||
| 935 | 1 | my $ok = 0; | |||||||||||||||||||||||||||
| 936 | 1 | ▶ | try { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 937 | 1 | $self->A->push_write( $type => @args ); | |||||||||||||||||||||||||||
| 938 | 1 | $ok = 1; | |||||||||||||||||||||||||||
| 939 | } | ||||||||||||||||||||||||||||
| 940 | 0 | ▶ | catch { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 941 | 0 | AE::log note => $_; | |||||||||||||||||||||||||||
| 942 | 1 | }; | |||||||||||||||||||||||||||
| 943 | 1 | $ok; | |||||||||||||||||||||||||||
| 944 | } | ||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||
| 946 | 1 | ▶ | sub writeln { | ||||||||||||||||||||||||||
|
Subroutine
writeln: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 947 | 1 | my ( $self, @lines ) = @_; | |||||||||||||||||||||||||||
| 948 | 1 | my $eol = $self->{proc}->_eol; | |||||||||||||||||||||||||||
| 949 | 1 | $self->write( $_ . $eol ) for @lines; | |||||||||||||||||||||||||||
| 950 | 1 | $self; | |||||||||||||||||||||||||||
| 951 | } | ||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||
| 953 | 0 | ▶ | sub pull { die 'UNIMPLEMENTED' } | ||||||||||||||||||||||||||
|
Subroutine
pull: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||
| 955 | 32 | 1; | |||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||
| 957 | package # hidden | ||||||||||||||||||||||||||||
| 958 | AnyEvent::Proc::TiedScalar; | ||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||
| 960 | 32 | ▶ | use Tie::Scalar; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||
| 962 | 32 | our @ISA = ('Tie::Scalar'); | |||||||||||||||||||||||||||
| 963 | |||||||||||||||||||||||||||||
| 964 | 1 | ▶ | sub TIESCALAR { | ||||||||||||||||||||||||||
|
Subroutine
TIESCALAR: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 965 | 1 | bless pop, shift; | |||||||||||||||||||||||||||
| 966 | } | ||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||
| 968 | 1 | ▶ | sub FETCH { | ||||||||||||||||||||||||||
|
Subroutine
FETCH: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 969 | 1 | undef; | |||||||||||||||||||||||||||
| 970 | } | ||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||
| 972 | 3 | ▶ | sub STORE { | ||||||||||||||||||||||||||
|
Subroutine
STORE: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 973 | 3 | shift->(pop); | |||||||||||||||||||||||||||
| 974 | } | ||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||
| 976 | 32 | 1; | |||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||
| 978 | __END__ | ||||||||||||||||||||||||||||