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   289 use strict;
  37         108  
  37         1076  
9 37     37   213 use warnings;
  37         75  
  37         985  
10 37     37   191 use base qw( IO::Async::Timer::Countdown );
  37         102  
  37         18045  
11              
12             our $VERSION = '0.47';
13              
14             sub _init
15             {
16 4     4   102 my $self = shift;
17 4         15 my ( $params ) = @_;
18 4         22 $self->SUPER::_init( $params );
19              
20 4         35 $self->{future} = delete $params->{future};
21             }
22              
23 14     14 0 89 sub reason :lvalue { shift->{stall_reason} }
24              
25             sub on_expire
26             {
27 4     4 1 402136 my $self = shift;
28              
29 4         31 my $conn = $self->parent;
30              
31 4         38 $self->{future}->fail( "Stalled while ${\$self->reason}", stall_timeout => );
  4         21  
32              
33 4         714 $conn->close_now;
34             }
35              
36             0x55AA;