File Coverage

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


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-2023 -- leonerd@leonerd.org.uk
5              
6             package Net::Async::HTTP::StallTimer 0.50;
7              
8 38     38   545 use v5.14;
  38         140  
9 38     38   265 use warnings;
  38         78  
  38         2326  
10 38     38   212 use base qw( IO::Async::Timer::Countdown );
  38         112  
  38         22274  
11              
12             sub _init
13             {
14 4     4   99 my $self = shift;
15 4         12 my ( $params ) = @_;
16 4         19 $self->SUPER::_init( $params );
17              
18 4         25 $self->{future} = delete $params->{future};
19             }
20              
21 14     14 0 93 sub reason :lvalue { shift->{stall_reason} }
22              
23             sub on_expire
24             {
25 4     4 1 401049 my $self = shift;
26              
27 4         25 my $conn = $self->parent;
28              
29 4         28 $self->{future}->fail( "Stalled while ${\$self->reason}", stall_timeout => );
  4         35  
30              
31 4         571 $conn->close_now;
32             }
33              
34             0x55AA;