Coro/HTTP.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 56 CC 5 SCAR 27.7
CC
5
Cov
0%
do_select
30.0
BEGIN
2.0
BEGIN
2.0
CRAP 16.0
1 package FurlX::Coro::HTTP;
2 use strict;
3 use warnings;
4  
5 use parent qw(Furl::HTTP);
6 use Coro::Select qw(select);
7 use Errno qw(EINTR);
8  
9 # just copied from Furl::HTTP
10 sub do_select {
11 my($self, $is_write, $sock, $timeout_at) = @_;
12 # wait for data
13 while (1) {
14 my $timeout = $timeout_at - time;
15 if ($timeout <= 0) {
16 $! = 0;
17 return 0;
18 }
19 my($rfd, $wfd);
20 my $efd = '';
21 vec($efd, fileno($sock), 1) = 1;
22 if ($is_write) {
23 $wfd = $efd;
24 } else {
25 $rfd = $efd;
26 }
27 my $nfound = select($rfd, $wfd, $efd, $timeout);
28 return 1 if $nfound > 0;
29 return 0 if $nfound == -1 && $! == EINTR && $self->{stop_if}->();
30 }
31 die 'not reached';
32 }
33  
34 1;
35 __END__