Uring.pm

filter: Statementstmt 29.2% 90 / 308 Branchbran 5.1% 9 / 176 Conditioncond 6.8% 5 / 73 MC/DCmcdc 0.0% 0 / 43 Subroutinesub 35.8% 24 / 67 Podpod 100% 16 / 16 totaltotal 21.0% 144 / 683 CC 121 SCAR 37.4
CC
121
Cov
19%
open
132.0
socket
110.0
timeout_until
90.0
CRAP 41.9
↑ Summary Uring/Handle.pm »
1 package Future::Uring;
2 5 $Future::Uring::VERSION = '0.005';
3 5 ▶use 5.020;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 ▶use experimental qw/signatures lexical_subs/;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 5 ▶use IO::Uring 0.012
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 qw/IOSQE_ASYNC IOSQE_IO_LINK IOSQE_IO_HARDLINK IOSQE_IO_DRAIN/,
9 qw/IORING_TIMEOUT_ABS IORING_TIMEOUT_BOOTTIME IORING_TIMEOUT_REALTIME IORING_TIMEOUT_ETIME_SUCCESS/,
10 qw/AT_SYMLINK_FOLLOW RENAME_EXCHANGE RENAME_NOREPLACE AT_REMOVEDIR/,
11 5 qw/P_PID P_PGID P_PIDFD P_ALL WEXITED WSTOPPED WCONTINUED WNOWAIT/;
12 5 ▶use IO::Uring::Singleton 'ring';
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 ▶use Carp 'croak';
Subroutine BEGIN: called CC=1 SCAR=0.0
14 5 ▶use Errno qw/ETIME/;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 5 ▶use Fcntl qw/O_RDONLY O_RDWR O_WRONLY O_APPEND O_CREAT O_DIRECT O_DSYNC O_EXCL O_NOFOLLOW O_SYNC/;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 5 ▶use Socket qw/AF_INET AF_INET6 AF_UNIX SOCK_STREAM SOCK_DGRAM SOCK_SEQPACKET SOCK_RAW/;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 5 ▶use IO::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 5 ▶use IO::Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 5 ▶use File::StatX qw/STATX_BASIC_STATS STATX_BTIME/;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 5 ▶use Signal::Info qw/CLD_EXITED CLD_DUMPED/;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 5 ▶use Time::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 5 ▶use Future::Uring::Handle;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 5 ▶use Future::Uring::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 3 ▶my sub to_sflags($args) {
Subroutine to_sflags: called CC=6 SCAR=20.3
27 3 my $result = 0;
28 3 ▶ $result |= IOSQE_ASYNC if $args->{async};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"async"} 0 3 3
29 3 ▶ $result |= IOSQE_IO_LINK if $args->{link} || $args->{timeout};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"link"} or $args->{"timeout"} 0 3 3
Condition33%1/3
$args->{"link"} or $args->{"timeout"}
l!l&&r!l&&!r
003
MC/DC0%0/2
$args->{"link"} or $args->{"timeout"}
$args->{"link"} $args->{"timeout"}
Truth table33%1/3
A or B
A= $args->{"link"}B= $args->{"timeout"}
ABresult
1X1
011
000
30 3 ▶ $result |= IOSQE_IO_HARDLINK if $args->{hardlink};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"hardlink"} 0 3 3
31 3 ▶ $result |= IOSQE_IO_DRAIN if $args->{drain};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"drain"} 0 3 3
32 3 return $result;
33 }
34  
35 5 my %clocks = (
36 monotonic => 0,
37 boottime => IORING_TIMEOUT_BOOTTIME,
38 realtime => IORING_TIMEOUT_REALTIME,
39 );
40  
41 0 ▶my sub add_timeout($ring, $args) {
Subroutine add_timeout: not called CC=6 SCAR=37.4
42 0 ▶ my $time_spec = ref $args->{timeout} ? $args->{timeout} : Time::Spec->new($args->{timeout});
Branch: 1 branch
BranchTrueFalseTotal
ref $args->{'timeout'} ? : 0 0 0
43 0 my ($flags, $s_flags) = (0, 0);
44 0 ▶ $flags |= $clocks{$args->{timeout_clock}} // croak("No such clock $args->{timeout_clock}") if $args->{timeout_clock};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"timeout_clock"} 0 0 0
Condition0%0/2
$clocks{$args->{"timeout_clock"}} // croak(qq[No such clock $args->{"timeout_clock"}])
l!l
00
MC/DC0%0/1
$clocks{$args->{"timeout_clock"}} // croak(qq[No such clock $args->{"timeout_clock"}])
$clocks{$args->{"timeout_clock"}}
Truth table0%0/2
A
A= $clocks{$args->{"timeout_clock"}}
Aresult
11
00
45 0 ▶ $flags |= IORING_TIMEOUT_ABS if $args->{timeout_absolute};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"timeout_absolute"} 0 0 0
46 0 ▶ $s_flags |= IOSQE_IO_LINK if $args->{link};
Branch: 1 branch
BranchTrueFalseTotal
if $args->{"link"} 0 0 0
47 0 $ring->link_timeout($time_spec, $flags, $s_flags);
48 0 return;
49 }
50  
51 13 ▶sub to_handle($fh) {
Subroutine to_handle: called CC=1 SCAR=0.0
Pod documented
52 13 return Future::Uring::Handle->new($fh);
53 }
54  
55 0 ▶sub run_once($timeout = undef) {
Subroutine run_once: not called CC=5 SCAR=34.0
Pod documented
56 0 my $ring = ring();
57 0 ▶ if (defined $timeout) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $timeout) { } 0 0 0
58 0 ▶ if ($timeout == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($timeout == 0) { } 0 0 0
59 0 return $ring->run_once(0);
60 } else {
61 0 ▶ my $timespec = ref($timeout) ? $timeout : Time::Spec->new($timeout);
Branch: 1 branch
BranchTrueFalseTotal
ref $timeout ? : 0 0 0
62 0 return $ring->run_once(1, $timespec);
63 }
64 } else {
65 0 return $ring->run_once(1);
66 }
67 }
68  
69 0 ▶sub submit() {
Subroutine submit: not called CC=1 SCAR=6.9
Pod documented
70 0 return ring->submit;
71 }
72  
73 0 ▶sub submissions_available() {
Subroutine submissions_available: not called CC=1 SCAR=6.9
Pod documented
74 0 return ring->sq_space_left;
75 }
76  
77 0 ▶sub link($old_path, $new_path, %args) {
Subroutine link: not called CC=7 SCAR=40.3
Pod documented
78 0 my $future = Future::Uring::_Future->new;
79 0 my (undef, $sourcename, $line) = caller;
80 0 ▶ my $s_flags = %args ? to_sflags(\%args) : 0;
Branch: 1 branch
BranchTrueFalseTotal
%args ? : 0 0 0
81 0 ▶ my $flags = $args{follow_symlink} ? AT_SYMLINK_FOLLOW : 0;
Branch: 1 branch
BranchTrueFalseTotal
$args{'follow_symlink'} ? : 0 0 0
82 0 my $ring = ring;
83 0 ▶ $ring->submit if $args{timeout} && $ring->sq_space_left < 2;
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} and $ring->sq_space_left < 2 0 0 0
Condition0%0/3
$args{"timeout"} and $ring->sq_space_left < 2
!ll&&!rl&&r
000
MC/DC0%0/2
$args{"timeout"} and $ring->sq_space_left < 2
$args{"timeout"} $ring->sq_space_left < 2
Truth table0%0/3
A and B
A= $args{"timeout"}B= $ring->sq_space_left < 2
ABresult
0X0
100
111
84 0 ▶ my $id = $ring->linkat($args{old_base}, $old_path, $args{new_base}, $new_path, $flags, $s_flags, sub($res, $flags) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
85 0 ▶ if ($res < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res < 0) { } 0 0 0
86 0 $future->fail(Future::Uring::Exception->new('link', $res, $sourcename, $line));
87 } else {
88 0 $future->done;
89 }
90 0 });
91 0 ▶ $future->on_cancel(sub { $ring->cancel($id, 0, 0) }) if $args{mutable};
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $args{"mutable"} 0 0 0
92 0 ▶ add_timeout($ring, \%args) if $args{timeout};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} 0 0 0
93 0 return $future;
94 }
95  
96 0 ▶sub mkdir($path, $mode, %args) {
Subroutine mkdir: not called CC=6 SCAR=37.4
Pod documented
97 0 my $future = Future::Uring::_Future->new;
98 0 my (undef, $sourcename, $line) = caller;
99 0 ▶ my $s_flags = %args ? to_sflags(\%args) : 0;
Branch: 1 branch
BranchTrueFalseTotal
%args ? : 0 0 0
100 0 my $ring = ring;
101 0 ▶ $ring->submit if $args{timeout} && $ring->sq_space_left < 2;
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} and $ring->sq_space_left < 2 0 0 0
Condition0%0/3
$args{"timeout"} and $ring->sq_space_left < 2
!ll&&!rl&&r
000
MC/DC0%0/2
$args{"timeout"} and $ring->sq_space_left < 2
$args{"timeout"} $ring->sq_space_left < 2
Truth table0%0/3
A and B
A= $args{"timeout"}B= $ring->sq_space_left < 2
ABresult
0X0
100
111
102 0 ▶ my $id = $ring->mkdirat($args{base}, $path, $mode, $s_flags, sub($res, $flags) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
103 0 ▶ if ($res < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res < 0) { } 0 0 0
104 0 $future->fail(Future::Uring::Exception->new('mkdir', $res, $sourcename, $line));
105 } else {
106 0 $future->done;
107 }
108 0 });
109 0 ▶ $future->on_cancel(sub { $ring->cancel($id, 0, 0) }) if $args{mutable};
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $args{"mutable"} 0 0 0
110 0 ▶ add_timeout($ring, \%args) if $args{timeout};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} 0 0 0
111 0 return $future;
112 }
113  
114 0 ▶sub nop(%args) {
Subroutine nop: not called CC=4 SCAR=30.0
Pod documented
115 0 my $future = Future::Uring::_Future->new;
116 0 my (undef, $sourcename, $line) = caller;
117 0 my $s_flags = to_sflags(\%args);
118 0 my $ring = ring;
119 0 ▶ $ring->ensure_sqes(2) if $args{timeout};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} 0 0 0
120 0 ▶ my $id = $ring->nop($s_flags, sub($res, $flags) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
121 0 ▶ if ($res < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res < 0) { } 0 0 0
122 0 $future->fail(Future::Uring::Exception->new('nop', $res, $sourcename, $line));
123 } else {
124 0 $future->done;
125 }
126 0 });
127 0 ▶ $future->on_cancel(sub { $ring->cancel($id, 0, 0) }) if $args{mutable};
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $args{"mutable"} 0 0 0
128 0 ▶ add_timeout($ring, \%args) if $args{timeout};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} 0 0 0
129 0 return $future;
130 }
131  
132 5 my %main_flags = (
133 '<' => O_RDONLY,
134 '+<' => O_RDWR,
135 '>' => O_WRONLY,
136 '+>' => O_RDWR | O_CREAT,
137 '>>' => O_APPEND,
138 );
139  
140 5 my %extra_flags = (
141 direct => O_DIRECT,
142 d_sync => O_DSYNC,
143 exclusive => O_EXCL,
144 no_follow => O_NOFOLLOW,
145 sync => O_SYNC,
146 );
147  
148 5 ▶use subs 'open';
Subroutine BEGIN: called CC=1 SCAR=0.0
149  
150 0 ▶sub open($filename, $open_mode = '<', %args) {
Subroutine open: not called CC=11 SCAR=48.8
151 0 my $future = Future::Uring::_Future->new;
152 0 my (undef, $sourcename, $line) = caller;
153 0 my $s_flags = to_sflags(\%args);
154 0 ▶ my $flags = $main_flags{$open_mode} // croak("Unknown mode '$open_mode'");
Condition0%0/2
$main_flags{$open_mode} // croak("Unknown mode '${open_mode}'")
l!l
00
MC/DC0%0/1
$main_flags{$open_mode} // croak("Unknown mode '${open_mode}'")
$main_flags{$open_mode}
Truth table0%0/2
A
A= $main_flags{$open_mode}
Aresult
11
00
155 0 ▶ $flags |= 0+$args{flags} if $args{flags};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"flags"} 0 0 0
156 0 for my $key (keys %extra_flags) {
157 0 ▶ $flags |= $extra_flags{$key} if $args{$key};
Branch: 1 branch
BranchTrueFalseTotal
if $args{$key} 0 0 0
158 }
159 0 ▶ my $mode = $args{mode} || 0777;
Condition0%0/2
$args{'mode'} || 511
l!l
00
MC/DC0%0/1
$args{'mode'} || 511
$args{'mode'}
Truth table0%0/2
A
A= $args{'mode'}
Aresult
11
00
160 0 my $ring = ring;
161 0 ▶ $ring->submit if $args{timeout} && $ring->sq_space_left < 2;
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} and $ring->sq_space_left < 2 0 0 0
Condition0%0/3
$args{"timeout"} and $ring->sq_space_left < 2
!ll&&!rl&&r
000
MC/DC0%0/2
$args{"timeout"} and $ring->sq_space_left < 2
$args{"timeout"} $ring->sq_space_left < 2
Truth table0%0/3
A and B
A= $args{"timeout"}B= $ring->sq_space_left < 2
ABresult
0X0
100
111
162 0 ▶ my $id = $ring->openat($args{base}, $filename, $flags, $mode, $s_flags, sub($res, $flags) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
163 0 ▶ if ($res >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res >= 0) { } 0 0 0
164 0 open my $fh, "$open_mode&=", $res;
165 0 $future->done(Future::Uring::Handle->new($fh));
166 } else {
167 0 $future->fail(Future::Uring::Exception->new('open', $res, $sourcename, $line));
168 }
169 0 });
170 0 ▶ $future->on_cancel(sub { $ring->cancel($id, 0, 0) }) if $args{mutable};
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $args{"mutable"} 0 0 0
171 0 ▶ add_timeout($ring, \%args) if $args{timeout};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} 0 0 0
172 0 return $future;
173 }
174  
175 0 ▶sub rename($old_path, $new_path, %args) {
Subroutine rename: not called CC=8 SCAR=42.8
Pod documented
176 0 my $future = Future::Uring::_Future->new;
177 0 my (undef, $sourcename, $line) = caller;
178 0 ▶ my $s_flags = %args ? to_sflags(\%args) : 0;
Branch: 1 branch
BranchTrueFalseTotal
%args ? : 0 0 0
179 0 my $flags = 0;
180 0 ▶ $flags |= RENAME_EXCHANGE if $args{exchange};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"exchange"} 0 0 0
181 0 ▶ $flags |= RENAME_NOREPLACE if $args{no_replace};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"no_replace"} 0 0 0
182 0 my $ring = ring;
183 0 ▶ $ring->submit if $args{timeout} && $ring->sq_space_left < 2;
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} and $ring->sq_space_left < 2 0 0 0
Condition0%0/3
$args{"timeout"} and $ring->sq_space_left < 2
!ll&&!rl&&r
000
MC/DC0%0/2
$args{"timeout"} and $ring->sq_space_left < 2
$args{"timeout"} $ring->sq_space_left < 2
Truth table0%0/3
A and B
A= $args{"timeout"}B= $ring->sq_space_left < 2
ABresult
0X0
100
111
184 0 ▶ my $id = $ring->renameat($args{old_base}, $old_path, $args{new_base}, $new_path, $flags, $s_flags, sub($res, $flags) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
185 0 ▶ if ($res < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res < 0) { } 0 0 0
186 0 $future->fail(Future::Uring::Exception->new('rename', $res, $sourcename, $line));
187 } else {
188 0 $future->done;
189 }
190 0 });
191 0 ▶ $future->on_cancel(sub { $ring->cancel($id, 0, 0) }) if $args{mutable};
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $args{"mutable"} 0 0 0
192 0 ▶ add_timeout($ring, \%args) if $args{timeout};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} 0 0 0
193 0 return $future;
194 }
195  
196 0 ▶sub rmdir($path, %args) {
Subroutine rmdir: not called CC=6 SCAR=37.4
Pod documented
197 0 my $future = Future::Uring::_Future->new;
198 0 my (undef, $sourcename, $line) = caller;
199 0 ▶ my $s_flags = %args ? to_sflags(\%args) : 0;
Branch: 1 branch
BranchTrueFalseTotal
%args ? : 0 0 0
200 0 my $ring = ring;
201 0 ▶ $ring->submit if $args{timeout} && $ring->sq_space_left < 2;
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} and $ring->sq_space_left < 2 0 0 0
Condition0%0/3
$args{"timeout"} and $ring->sq_space_left < 2
!ll&&!rl&&r
000
MC/DC0%0/2
$args{"timeout"} and $ring->sq_space_left < 2
$args{"timeout"} $ring->sq_space_left < 2
Truth table0%0/3
A and B
A= $args{"timeout"}B= $ring->sq_space_left < 2
ABresult
0X0
100
111
202 0 ▶ my $id = $ring->unlinkat($args{base}, $path, AT_REMOVEDIR, $s_flags, sub($res, $flags) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
203 0 ▶ if ($res < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res < 0) { } 0 0 0
204 0 $future->fail(Future::Uring::Exception->new('rmdir', $res, $sourcename, $line));
205 } else {
206 0 $future->done;
207 }
208 0 });
209 0 ▶ $future->on_cancel(sub { $ring->cancel($id, 0, 0) }) if $args{mutable};
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $args{"mutable"} 0 0 0
210 0 ▶ add_timeout($ring, \%args) if $args{timeout};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} 0 0 0
211 0 return $future;
212 }
213  
214 5 my %family_for = (
215 inet => AF_INET,
216 inet6 => AF_INET6,
217 unix => AF_UNIX,
218 );
219  
220 5 my %type_for = (
221 stream => SOCK_STREAM,
222 datagram => SOCK_DGRAM,
223 seqpacket => SOCK_SEQPACKET,
224 raw => SOCK_RAW,
225 );
226  
227 0 ▶sub socket($family_name, %args) {
Subroutine socket: not called CC=10 SCAR=47.0
Pod documented
228 0 my $future = Future::Uring::_Future->new;
229 0 my (undef, $sourcename, $line) = caller;
230 0 ▶ my $domain = $family_for{$family_name} // croak "No address family '$family_name' known";
Condition0%0/2
$family_for{$family_name} // croak("No address family '${family_name}' known")
l!l
00
MC/DC0%0/1
$family_for{$family_name} // croak("No address family '${family_name}' known")
$family_for{$family_name}
Truth table0%0/2
A
A= $family_for{$family_name}
Aresult
11
00
231 0 ▶ my $type = defined $args{type} ? $type_for{$args{type}} : SOCK_STREAM;
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'type'} ? : 0 0 0
232 0 ▶ my $protocol = defined $args{protocol} ? getprotobyname($args{protocol}) : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'protocol'} ? : 0 0 0
233 0 ▶ my $s_flags = %args ? to_sflags(\%args) : 0;
Branch: 1 branch
BranchTrueFalseTotal
%args ? : 0 0 0
234 0 my $ring = ring;
235 0 ▶ $ring->submit if $args{timeout} && $ring->sq_space_left < 2;
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} and $ring->sq_space_left < 2 0 0 0
Condition0%0/3
$args{"timeout"} and $ring->sq_space_left < 2
!ll&&!rl&&r
000
MC/DC0%0/2
$args{"timeout"} and $ring->sq_space_left < 2
$args{"timeout"} $ring->sq_space_left < 2
Truth table0%0/3
A and B
A= $args{"timeout"}B= $ring->sq_space_left < 2
ABresult
0X0
100
111
236 0 ▶ my $class = $args{class} // 'IO::Socket';
Condition0%0/2
$args{"class"} // "IO::Socket"
l!l
00
MC/DC0%0/1
$args{"class"} // "IO::Socket"
$args{"class"}
Truth table0%0/2
A
A= $args{"class"}
Aresult
11
00
237 0 ▶ my $id = $ring->socket($domain, $type, $protocol, $s_flags, sub($res, $flags) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
238 0 ▶ if ($res >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res >= 0) { } 0 0 0
239 0 my $fh = $class->new_from_fd($res);
240 0 $future->done(Future::Uring::Handle->new($fh));
241 } else {
242 0 $future->fail(Future::Uring::Exception->new('socket', $res, $sourcename, $line));
243 }
244 0 });
245 0 ▶ $future->on_cancel(sub { $ring->cancel($id, 0, 0) }) if $args{mutable};
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $args{"mutable"} 0 0 0
246 0 ▶ add_timeout($ring, \%args) if $args{timeout};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} 0 0 0
247 0 return $future;
248 }
249  
250 0 ▶sub statx($path, %args) {
Subroutine statx: not called CC=8 SCAR=42.8
Pod documented
251 0 my $future = Future::Uring::_Future->new;
252 0 my (undef, $sourcename, $line) = caller;
253 0 ▶ my $flags = $args{flags} // 0;
Condition0%0/2
$args{"flags"} // 0
l!l
00
MC/DC0%0/1
$args{"flags"} // 0
$args{"flags"}
Truth table0%0/2
A
A= $args{"flags"}
Aresult
11
00
254 0 ▶ my $mask = $args{mask} // STATX_BASIC_STATS | STATX_BTIME;
Condition0%0/2
$args{"mask"} // 4095
l!l
00
MC/DC0%0/1
$args{"mask"} // 4095
$args{"mask"}
Truth table0%0/2
A
A= $args{"mask"}
Aresult
11
00
255 0 my $stat = File::StatX->new;
256 0 ▶ my $s_flags = %args ? to_sflags(\%args) : 0;
Branch: 1 branch
BranchTrueFalseTotal
%args ? : 0 0 0
257 0 my $ring = ring;
258 0 ▶ $ring->submit if $args{timeout} && $ring->sq_space_left < 2;
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} and $ring->sq_space_left < 2 0 0 0
Condition0%0/3
$args{"timeout"} and $ring->sq_space_left < 2
!ll&&!rl&&r
000
MC/DC0%0/2
$args{"timeout"} and $ring->sq_space_left < 2
$args{"timeout"} $ring->sq_space_left < 2
Truth table0%0/3
A and B
A= $args{"timeout"}B= $ring->sq_space_left < 2
ABresult
0X0
100
111
259 0 ▶ my $id = $ring->statx($args{base}, $path, $flags, $mask, $stat, $s_flags, sub($res, $flags) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
260 0 ▶ if ($res >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res >= 0) { } 0 0 0
261 0 $future->done($stat);
262 } else {
263 0 $future->fail(Future::Uring::Exception->new('statx', $res, $sourcename, $line));
264 }
265 0 });
266 0 ▶ $future->on_cancel(sub { $ring->cancel($id, 0, 0) }) if $args{mutable};
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $args{"mutable"} 0 0 0
267 0 ▶ add_timeout($ring, \%args) if $args{timeout};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} 0 0 0
268 0 return $future;
269 }
270  
271 2 ▶sub timeout_for($seconds, %args) {
Subroutine timeout_for: called CC=9 SCAR=36.6
Pod documented
272 2 my $future = Future::Uring::_Future->new;
273 2 my (undef, $sourcename, $line) = caller;
274 2 ▶ my $time_spec = ref $seconds ? $seconds : Time::Spec->new($seconds);
Branch: 1 branch
BranchTrueFalseTotal
ref $seconds ? : 0 2 2
275 2 ▶ my $clock_id = $args{clock} ? $clocks{$args{clock}} // croak("No such clock $args{clock}") : 0;
Branch: 1 branch
BranchTrueFalseTotal
$args{'clock'} ? : 0 2 2
Condition0%0/2
$clocks{$args{"clock"}} // croak(qq[No such clock $args{"clock"}])
l!l
00
MC/DC0%0/1
$clocks{$args{"clock"}} // croak(qq[No such clock $args{"clock"}])
$clocks{$args{"clock"}}
Truth table0%0/2
A
A= $clocks{$args{"clock"}}
Aresult
11
00
276 2 my $flags = $clock_id | IORING_TIMEOUT_ETIME_SUCCESS;
277 2 ▶ my $counter = $args{counter} // 0;
Condition50%1/2
$args{"counter"} // 0
l!l
02
MC/DC0%0/1
$args{"counter"} // 0
$args{"counter"}
Truth table50%1/2
A
A= $args{"counter"}
Aresult
11
00
278 2 my $s_flags = to_sflags(\%args);
279 2 my $ring = ring;
280 0 ▶ $ring->submit if $args{timeout} && $ring->sq_space_left < 2;
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} and $ring->sq_space_left < 2 0 0 0
Condition0%0/3
$args{"timeout"} and $ring->sq_space_left < 2
!ll&&!rl&&r
000
MC/DC0%0/2
$args{"timeout"} and $ring->sq_space_left < 2
$args{"timeout"} $ring->sq_space_left < 2
Truth table0%0/3
A and B
A= $args{"timeout"}B= $ring->sq_space_left < 2
ABresult
0X0
100
111
281 0 ▶ my $id = $ring->timeout($time_spec, $counter, $flags, $s_flags, sub($res, $flags) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
282 0 ▶ if ($res != -ETIME) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res != -62) { } 0 0 0
283 0 $future->fail(Future::Uring::Exception->new('timeout', $res, $sourcename, $line));
284 } else {
285 0 $future->done;
286 }
287 0 });
288 0 ▶ if ($args{mutable}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"mutable"}) 0 0 0
289 0 bless $future, 'Future::Uring::_TimeoutFuture';
290 0 $future->set_udata('uring_id', $id);
291 0 ▶ $future->on_cancel(sub { $ring->cancel($id, 0, 0) });
Subroutine __ANON__: not called CC=1 SCAR=6.9
292 }
293 0 ▶ add_timeout($ring, \%args) if $args{timeout};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} 0 0 0
294 0 return $future;
295 }
296  
297 0 ▶sub timeout_until($seconds, %args) {
Subroutine timeout_until: not called CC=9 SCAR=45.0
Pod documented
298 0 my $future = Future::Uring::_Future->new;
299 0 my (undef, $sourcename, $line) = caller;
300 0 ▶ my $time_spec = ref $seconds ? $seconds : Time::Spec->new($seconds);
Branch: 1 branch
BranchTrueFalseTotal
ref $seconds ? : 0 0 0
301 0 ▶ my $clock_id = $args{clock} ? $clocks{$args{clock}} // croak("No such clock $args{clock}") : IORING_TIMEOUT_REALTIME;
Branch: 1 branch
BranchTrueFalseTotal
$args{'clock'} ? : 0 0 0
Condition0%0/2
$clocks{$args{"clock"}} // croak(qq[No such clock $args{"clock"}])
l!l
00
MC/DC0%0/1
$clocks{$args{"clock"}} // croak(qq[No such clock $args{"clock"}])
$clocks{$args{"clock"}}
Truth table0%0/2
A
A= $clocks{$args{"clock"}}
Aresult
11
00
302 0 my $flags = $clock_id | IORING_TIMEOUT_ETIME_SUCCESS | IORING_TIMEOUT_ABS;
303 0 ▶ my $counter = $args{counter} // 0;
Condition0%0/2
$args{"counter"} // 0
l!l
00
MC/DC0%0/1
$args{"counter"} // 0
$args{"counter"}
Truth table0%0/2
A
A= $args{"counter"}
Aresult
11
00
304 0 my $s_flags = to_sflags(\%args);
305 0 my $ring = ring;
306 0 ▶ $ring->submit if $args{timeout} && $ring->sq_space_left < 2;
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} and $ring->sq_space_left < 2 0 0 0
Condition0%0/3
$args{"timeout"} and $ring->sq_space_left < 2
!ll&&!rl&&r
000
MC/DC0%0/2
$args{"timeout"} and $ring->sq_space_left < 2
$args{"timeout"} $ring->sq_space_left < 2
Truth table0%0/3
A and B
A= $args{"timeout"}B= $ring->sq_space_left < 2
ABresult
0X0
100
111
307 0 ▶ my $id = $ring->timeout($time_spec, $counter, $flags, $s_flags, sub($res, $flags) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
308 0 ▶ if ($res != -ETIME) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res != -62) { } 0 0 0
309 0 $future->fail(Future::Uring::Exception->new('timeout', $res, $sourcename, $line));
310 } else {
311 0 $future->done;
312 }
313 0 });
314 0 ▶ if ($args{mutable}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"mutable"}) 0 0 0
315 0 bless $future, 'Future::Uring::_TimeoutFuture';
316 0 $future->set_udata('uring_id', $id);
317 0 ▶ $future->on_cancel(sub { $ring->cancel($id, 0, 0) });
Subroutine __ANON__: not called CC=1 SCAR=6.9
318 }
319 0 ▶ add_timeout($ring, \%args) if $args{timeout};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} 0 0 0
320 0 return $future;
321 }
322  
323 0 ▶sub unlink($path, %args) {
Subroutine unlink: not called CC=6 SCAR=37.4
Pod documented
324 0 my $future = Future::Uring::_Future->new;
325 0 my (undef, $sourcename, $line) = caller;
326 0 ▶ my $s_flags = %args ? to_sflags(\%args) : 0;
Branch: 1 branch
BranchTrueFalseTotal
%args ? : 0 0 0
327 0 my $ring = ring;
328 0 ▶ $ring->submit if $args{timeout} && $ring->sq_space_left < 2;
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} and $ring->sq_space_left < 2 0 0 0
Condition0%0/3
$args{"timeout"} and $ring->sq_space_left < 2
!ll&&!rl&&r
000
MC/DC0%0/2
$args{"timeout"} and $ring->sq_space_left < 2
$args{"timeout"} $ring->sq_space_left < 2
Truth table0%0/3
A and B
A= $args{"timeout"}B= $ring->sq_space_left < 2
ABresult
0X0
100
111
329 0 ▶ my $id = $ring->unlinkat($args{base}, $path, 0, $s_flags, sub($res, $flags) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
330 0 ▶ if ($res < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res < 0) { } 0 0 0
331 0 $future->fail(Future::Uring::Exception->new('unlink', $res, $sourcename, $line));
332 } else {
333 0 $future->done;
334 }
335 0 });
336 0 ▶ $future->on_cancel(sub { $ring->cancel($id, 0, 0) }) if $args{mutable};
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $args{"mutable"} 0 0 0
337 0 ▶ add_timeout($ring, \%args) if $args{timeout};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} 0 0 0
338 0 return $future;
339 }
340  
341 5 my %types = (
342 pid => P_PID,
343 pgid => P_PGID,
344 pidfd => P_PIDFD,
345 all => P_ALL,
346 );
347  
348 5 my %events = (
349 exited => WEXITED,
350 stopped => WSTOPPED,
351 continued => WCONTINUED,
352 );
353  
354 1 ▶sub waitid($type_name, $id, %args) {
Subroutine waitid: called CC=12 SCAR=40.0
Pod documented
355 1 my $future = Future::Uring::_Future->new;
356 1 my (undef, $sourcename, $line) = caller;
357 1 ▶ my $type = $types{$type_name} // croak "Unknown wait type $type_name";
Condition50%1/2
$types{$type_name} // croak("Unknown wait type $type_name")
l!l
10
MC/DC0%0/1
$types{$type_name} // croak("Unknown wait type $type_name")
$types{$type_name}
Truth table50%1/2
A
A= $types{$type_name}
Aresult
11
00
358 1 my $info = Signal::Info->new;
359 1 my $s_flags = to_sflags(\%args);
360 1 ▶ my $event = defined $args{event} ? $events{$args{event}} // croak("No such event $args{event}") : WEXITED;
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'event'} ? : 0 1 1
Condition0%0/2
$events{$args{"event"}} // croak(qq[No such event $args{"event"}])
l!l
00
MC/DC0%0/1
$events{$args{"event"}} // croak(qq[No such event $args{"event"}])
$events{$args{"event"}}
Truth table0%0/2
A
A= $events{$args{"event"}}
Aresult
11
00
361 1 ▶ $event |= WNOWAIT if $args{nowait};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"nowait"} 0 1 1
362 1 ▶ $id = $id->fileno if $type_name eq 'pidfd' && Scalar::Util::blessed($id) && $id->isa('Linux::FD::Pid');
Branch: 1 branch
BranchTrueFalseTotal
if $type_name eq "pidfd" and builtin::blessed($id) and $id->isa("Linux::FD::Pid") 0 1 1
Condition33%2/6
$type_name eq "pidfd" and builtin::blessed($id) and $id->isa("Linux::FD::Pid")
!ll&&!rl&&r
100
$type_name eq "pidfd" and builtin::blessed($id)
!ll&&!rl&&r
100
MC/DC0%0/3
$type_name eq "pidfd" and builtin::blessed($id) and $id->isa("Linux::FD::Pid")
$type_name eq "pidfd" builtin::blessed($id) $id->isa("Linux::FD::Pid")
Truth table25%1/4
A and B and C
A= $type_name eq "pidfd"B= builtin::blessed($id)C= $id->isa("Linux::FD::Pid")
ABCresult
0XX0
10X0
1100
1111
363 1 my $ring = ring;
364 0 ▶ $ring->submit if $args{timeout} && $ring->sq_space_left < 2;
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} and $ring->sq_space_left < 2 0 0 0
Condition0%0/3
$args{"timeout"} and $ring->sq_space_left < 2
!ll&&!rl&&r
000
MC/DC0%0/2
$args{"timeout"} and $ring->sq_space_left < 2
$args{"timeout"} $ring->sq_space_left < 2
Truth table0%0/3
A and B
A= $args{"timeout"}B= $ring->sq_space_left < 2
ABresult
0X0
100
111
365  
366 0 ▶ my $ident = $ring->waitid($type, $id, $info, $event, 0, $s_flags, sub($res, $flags) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
367 0 ▶ if ($res >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res >= 0) { } 0 0 0
368 0 $future->done($info);
369 } else {
370 0 $future->fail(Future::Uring::Exception->new('waitid', $res, $sourcename, $line));
371 }
372 0 });
373  
374 0 ▶ $future->on_cancel(sub { $ring->cancel($ident, 0, 0) }) if $args{mutable};
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $args{"mutable"} 0 0 0
375 0 ▶ add_timeout($ring, \%args) if $args{timeout};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} 0 0 0
376 0 return $future;
377 }
378  
379 1 ▶sub waitpid($pid, %args) {
Subroutine waitpid: called CC=1 SCAR=5.3
Pod documented
380 1 my $first = waitid('pid', $pid, %args);
381 0 ▶ return $first->then(sub($info) {
Subroutine __ANON__: not called CC=3 SCAR=24.8
382 0 my $second = Future->new;
383 0 ▶ my $status = $info->code == CLD_EXITED ? ($info->status << 8) :
Branch: 2 branches
BranchTrueFalseTotal
$info->code == 1 ? : 0 0 0
$info->code == 3 ? : 0 0 0
384 $info->code == CLD_DUMPED ? $info->status | 128 : $info->status;
385 0 $second->done($status);
386 0 });
387 }
388  
389 # ABSTRACT: Future-returning io_uring functions
390  
391 package
392 Future::Uring::_Future;
393  
394 5 ▶use parent 'Future';
Subroutine BEGIN: called CC=1 SCAR=0.0
395  
396 0 ▶sub await($self) {
Subroutine await: not called CC=2 SCAR=17.9
397 0 my $ring = Future::Uring::ring;
398 0 ▶ $ring->run_once until $self->is_ready;
Branch: 1 branch
BranchTrueFalseTotal
$self->is_ready or do { $ring->run_once } 0 0 0
399 0 return $self;
400 }
401  
402 package
403 Future::Uring::_TimeoutFuture;
404  
405 5 ▶use parent -norequire, 'Future::Uring::_Future';
Subroutine BEGIN: called CC=1 SCAR=0.0
406  
407 0 ▶sub update($original, $seconds, %args) {
Subroutine update: not called CC=7 SCAR=40.3
408 0 my $future = Future::Uring::_Future->new;
409 0 my (undef, $sourcename, $line) = caller;
410 0 my $id = $original->udata('uring_id');
411  
412 0 ▶ my $time_spec = ref $seconds ? $seconds : Time::Spec->new($seconds);
Branch: 1 branch
BranchTrueFalseTotal
ref $seconds ? : 0 0 0
413 0 ▶ my $flags = $args{flags} // 0;
Condition0%0/2
$args{"flags"} // 0
l!l
00
MC/DC0%0/1
$args{"flags"} // 0
$args{"flags"}
Truth table0%0/2
A
A= $args{"flags"}
Aresult
11
00
414 0 my $s_flags = to_sflags(\%args);
415 0 my $ring = Future::Uring::ring();
416 0 ▶ $ring->submit if $args{timeout} && $ring->sq_space_left < 2;
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} and $ring->sq_space_left < 2 0 0 0
Condition0%0/3
$args{"timeout"} and $ring->sq_space_left < 2
!ll&&!rl&&r
000
MC/DC0%0/2
$args{"timeout"} and $ring->sq_space_left < 2
$args{"timeout"} $ring->sq_space_left < 2
Truth table0%0/3
A and B
A= $args{"timeout"}B= $ring->sq_space_left < 2
ABresult
0X0
100
111
417 0 ▶ $ring->timeout_update($time_spec, $id, $flags, $s_flags, sub($res, $flags) {
Subroutine __ANON__: not called CC=2 SCAR=17.9
418 0 ▶ if ($res < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res < 0) { } 0 0 0
419 0 $future->fail(Future::Uring::Exception->new('timeout_update', $res, $sourcename, $line));
420 } else {
421 0 $future->done;
422 }
423 0 $time_spec;
424 0 });
425 0 ▶ $future->on_cancel(sub { $ring->cancel($id, 0, 0) }) if $args{mutable};
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $args{"mutable"} 0 0 0
426 0 ▶ add_timeout($ring, \%args) if $args{timeout};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"timeout"} 0 0 0
427 0 return $future;
428 }
429  
430  
431 5 1;
432  
433 # ABSTRACT: Future returning uring methods
434  
435 __END__
↑ Summary Uring/Handle.pm »