File: StallTimer.pm

package info (click to toggle)
libnet-async-http-perl 0.50-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 436 kB
  • sloc: perl: 5,029; sh: 2; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 681 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#  You may distribute under the terms of either the GNU General Public License
#  or the Artistic License (the same terms as Perl itself)
#
#  (C) Paul Evans, 2014-2023 -- leonerd@leonerd.org.uk

package Net::Async::HTTP::StallTimer 0.50;

use v5.14;
use warnings;
use base qw( IO::Async::Timer::Countdown );

sub _init
{
   my $self = shift;
   my ( $params ) = @_;
   $self->SUPER::_init( $params );

   $self->{future} = delete $params->{future};
}

sub reason :lvalue { shift->{stall_reason} }

sub on_expire
{
   my $self = shift;

   my $conn = $self->parent;

   $self->{future}->fail( "Stalled while ${\$self->reason}", stall_timeout => );

   $conn->close_now;
}

0x55AA;