File Coverage

blib/lib/Feersum/Connection.pm
Criterion Covered Total %
statement 30 31 96.7
branch n/a
condition n/a
subroutine 10 11 90.9
pod 1 1 100.0
total 41 43 95.3


line stmt bran cond sub pod time code
1             package Feersum::Connection;
2 124     124   717 use warnings;
  124         178  
  124         6832  
3 124     124   644 use strict;
  124         173  
  124         2679  
4 124     124   467 use Carp qw/croak/;
  124         167  
  124         6924  
5 124     124   2907 use IO::Socket::INET;
  124         93732  
  124         2861  
6              
7             sub new {
8 0     0 1 0 croak "Cannot instantiate Feersum::Connection directly";
9             }
10              
11             sub _initiate_streaming_psgi {
12 16     16   177774 my ($self, $streamer) = @_;
13 16     7   120 return $streamer->(sub { $self->_continue_streaming_psgi(@_) });
  7         1044895  
14             }
15              
16             my $_pkg = "Feersum::";
17             sub _raw { ## no critic (RequireArgUnpacking)
18             # don't shift; want to modify $_[0] directly.
19 15     15   2202210 my $fileno = $_[1];
20 15         77 my $name = "RAW$fileno";
21             # Hack to make gensyms via new_from_fd() show up in the Feersum package.
22             # This may or may not save memory (HEKs?) over true gensyms.
23 124     124   74330 no warnings 'redefine';
  124         261  
  124         7645  
24             local *IO::Handle::gensym = sub {
25 124     124   728 no strict;
  124         742  
  124         14420  
26 15     15   175 my $gv = \*{$_pkg.$name};
  15         236  
27 15         43 delete $$_pkg{$name};
28 15         91 $gv;
29 15         864 };
30             # Replace $_[0] directly:
31 15         318 $_[0] = IO::Socket::INET->new_from_fd($fileno, '+<');
32             # after this, Feersum will use PerlIO_unread to put any remainder data
33             # into the socket.
34 15         1633 return;
35             }
36             1;
37             __END__