File Coverage

blib/lib/Net/Async/HTTP/StallTimer.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 1 2 50.0
total 26 27 96.3


line stmt bran cond sub pod time code
1             # You may distribute under the terms of either the GNU General Public License
2             # or the Artistic License (the same terms as Perl itself)
3             #
4             # (C) Paul Evans, 2014 -- leonerd@leonerd.org.uk
5              
6             package Net::Async::HTTP::StallTimer;
7              
8 37     37   276 use strict;
  37         84  
  37         1107  
9 37     37   190 use warnings;
  37         75  
  37         1127  
10 37     37   194 use base qw( IO::Async::Timer::Countdown );
  37         70  
  37         19202  
11              
12             our $VERSION = '0.48';
13              
14             sub _init
15             {
16 4     4   75 my $self = shift;
17 4         12 my ( $params ) = @_;
18 4         18 $self->SUPER::_init( $params );
19              
20 4         21 $self->{future} = delete $params->{future};
21             }
22              
23 14     14 0 74 sub reason :lvalue { shift->{stall_reason} }
24              
25             sub on_expire
26             {
27 4     4 1 401803 my $self = shift;
28              
29 4         20 my $conn = $self->parent;
30              
31 4         27 $self->{future}->fail( "Stalled while ${\$self->reason}", stall_timeout => );
  4         17  
32              
33 4         510 $conn->close_now;
34             }
35              
36             0x55AA;