line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Coro::PatchSet::Handle; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
20765
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
78
|
|
4
|
3
|
|
|
3
|
|
4144
|
use Coro::Handle; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.12'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package # hide it from cpan |
9
|
|
|
|
|
|
|
Coro::Handle; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new_from_fh { |
12
|
|
|
|
|
|
|
my $class = shift; |
13
|
|
|
|
|
|
|
my $fh = shift or return; |
14
|
|
|
|
|
|
|
open my $self, '+<&', $fh or return; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
tie *$self, 'Coro::Handle::FH', fh => $fh, @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
bless $self, ref $class ? ref $class : $class |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
package # hide it from cpan |
22
|
|
|
|
|
|
|
Coro::Handle::FH; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub READ { |
25
|
|
|
|
|
|
|
my $len = $_[2]; |
26
|
|
|
|
|
|
|
my $ofs = $_[3]; |
27
|
|
|
|
|
|
|
my $res; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# first deplete the read buffer |
30
|
|
|
|
|
|
|
if (length $_[0][3]) { |
31
|
|
|
|
|
|
|
my $l = length $_[0][3]; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
if ($l <= $len) { |
34
|
|
|
|
|
|
|
substr ($_[1], $ofs) = $_[0][3]; $_[0][3] = ""; |
35
|
|
|
|
|
|
|
return $l; |
36
|
|
|
|
|
|
|
} else { |
37
|
|
|
|
|
|
|
substr ($_[1], $ofs) = substr ($_[0][3], 0, $len); |
38
|
|
|
|
|
|
|
substr ($_[0][3], 0, $len) = ""; |
39
|
|
|
|
|
|
|
return $len; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
while() { |
44
|
|
|
|
|
|
|
my $r = sysread $_[0][0], $_[1], $len, $ofs; |
45
|
|
|
|
|
|
|
if (defined $r) { |
46
|
|
|
|
|
|
|
$len -= $r; |
47
|
|
|
|
|
|
|
$ofs += $r; |
48
|
|
|
|
|
|
|
$res += $r; |
49
|
|
|
|
|
|
|
last; |
50
|
|
|
|
|
|
|
} elsif ($! != EAGAIN && $! != EINTR && $! != WSAEWOULDBLOCK) { |
51
|
|
|
|
|
|
|
last; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
last if $_[0][8] || !&readable; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
$res |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |