Virt/Connection.pm

filter: Statementstmt 34.4% 42 / 122 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 36.3% 8 / 22 Podpod 50.0% 4 / 8 totaltotal 31.2% 54 / 173 CC 10 SCAR 18.7
CC
10
Cov
30%
write
20.0
_finalize_io
12.0
read
12.0
CRAP 6.5
« Virt/Network.pm ↑ Summary Virt/DomainCheckpoint.pm »
1 ####################################################################
2 #
3 # This file was generated using XDR::Parse version v1.0.1
4 # and LibVirt version v12.9.0
5 #
6 # Don't edit this file, use the source template instead
7 #
8 # ANY CHANGES HERE WILL BE LOST !
9 #
10 ####################################################################
11  
12  
13 1 ▶use v5.26;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use experimental 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Future::AsyncAwait;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use Object::Pad ':experimental(inherit_field)';
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 class Sys::Async::Virt::Connection v0.6.9;
20  
21 1 field $_in :inheritable = undef;
22 1 field $_out :inheritable = undef;
23  
24 # Futures indicating status of the last read/write action
25 1 field $_read_f = Future->done;
26 1 field $_write_f = Future->done;
27 1 field $_eof;
28  
29 1 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
30 1 ▶use Future::IO;
Subroutine BEGIN: called CC=1 SCAR=0.0
31 1 ▶use Log::Any qw($log);
Subroutine BEGIN: called CC=1 SCAR=0.0
32  
33 0 ▶method _finalize_io() {
Subroutine _finalize_io: not called CC=3 SCAR=24.8
34 0 $_eof = 1;
35 0 ▶ $_write_f->fail( 'closed' ) unless $_write_f->is_ready;
Branch: 1 branch
BranchTrueFalseTotal
unless $_write_f->is_ready 0 0 0
36 0 ▶ $_read_f->fail( 'closed' ) unless $_read_f->is_ready;
Branch: 1 branch
BranchTrueFalseTotal
unless $_read_f->is_ready 0 0 0
37 0 $_read_f = Future->fail( 'closed' );
38 0 $_write_f = Future->fail( 'closed' );
39 1 }
40  
41 0 ▶async method close() {
Subroutine close: not called CC=1 SCAR=6.9
Pod undocumented
42 0 die $log->fatal(
43 "The 'close' method must be implemented by concrete sub-classes");
44 1 }
45  
46 0 ▶async method connect() {
Subroutine connect: not called CC=1 SCAR=6.9
Pod documented
47 0 die $log->fatal(
48 "The 'connect' method must be implemented by concrete sub-classes");
49 1 }
50  
51 0 ▶method connected() {
Subroutine connected: not called CC=2 SCAR=17.9
Pod undocumented
52 0 ▶ return ($_in and $_out);
Condition0%0/3
$_in && $_out
!ll&&!rl&&r
000
MC/DC0%0/2
$_in && $_out
$_in $_out
Truth table0%0/3
A && B
A= $_inB= $_out
ABresult
0X0
100
111
53 1 }
54  
55 0 ▶method is_read_eof() {
Subroutine is_read_eof: not called CC=1 SCAR=6.9
Pod undocumented
56 0 return $_eof;
57 1 }
58  
59 0 ▶method is_secure() {
Subroutine is_secure: not called CC=1 SCAR=6.9
Pod documented
60 0 return 0;
61 1 }
62  
63 0 ▶method is_write_eof() {
Subroutine is_write_eof: not called CC=1 SCAR=6.9
Pod undocumented
64 0 return $_eof;
65 1 }
66  
67 0 ▶method _read_internal( $len ) {
Subroutine _read_internal: not called CC=1 SCAR=6.9
68 0 Future::IO->read_exactly( $_in, $len )
69 1 }
70  
71 0 ▶async method read($type, $len) {
Subroutine read: not called CC=3 SCAR=24.8
Pod documented
72 0 ▶ die $log->fatal( "Unsupported transfer type $type" ) unless $type eq 'data';
Branch: 1 branch
BranchTrueFalseTotal
unless $type eq "data" 0 0 0
73 0 ▶ return (undef, 1) if $_eof;
Branch: 1 branch
BranchTrueFalseTotal
if $_eof 0 0 0
74  
75 0 $log->trace( "Starting read of length $len" );
76 0 ▶ $_read_f = $_read_f->then(sub { $self->_read_internal( $len ) });
Subroutine __ANON__: not called CC=1 SCAR=6.9
77  
78 0 my $data = await $_read_f;
79 0 $log->trace( "Finished read of length $len" );
80 0 $_eof = not defined $data;
81  
82 0 return ($data, 0);
83 1 }
84  
85 0 ▶method _write_internal( $data ) {
Subroutine _write_internal: not called CC=1 SCAR=6.9
86 0 Future::IO->write_exactly( $_out, $data )
87 1 }
88  
89 0 ▶method _write_chunk($data) {
Subroutine _write_chunk: not called CC=2 SCAR=17.9
90 0 ▶ die "Write to closed file" if $_eof;
Branch: 1 branch
BranchTrueFalseTotal
if $_eof 0 0 0
91  
92 0 $log->trace( 'Low-level write of ' . length($data) . ' bytes' );
93 0 ▶ $_write_f = $_write_f->then(sub { $self->_write_internal( $data ) });
Subroutine __ANON__: not called CC=1 SCAR=6.9
94 0 return $_write_f;
95 1 }
96  
97  
98 0 ▶async method write(@data) {
Subroutine write: not called CC=4 SCAR=30.0
Pod documented
99 0 ▶ return if @data == 0;
Branch: 1 branch
BranchTrueFalseTotal
if @data == 0 0 0 0
100  
101 # use the first data element as backpressure
102 # but don't await it here: we want to send
103 # all data into the send queue at once, so
104 # other write calls can't mix their data
105 # with ours
106 0 my $f = $self->_write_chunk( shift @data );
107  
108 0 ▶ while (@data) {
Branch: 1 branch
BranchTrueFalseTotal
if (@data) 0 0 0
109 0 my $data = shift @data;
110 0 ▶ next unless $data;
Branch: 1 branch
BranchTrueFalseTotal
unless $data 0 0 0
111  
112 0 $self->_write_chunk( $data );
113 }
114  
115 0 return await $f;
116 1 }
117  
118 1 1;
119  
120 __END__
« Virt/Network.pm ↑ Summary Virt/DomainCheckpoint.pm »