ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/IO-AIO/AIO.pm
(Generate patch)

Comparing IO-AIO/AIO.pm (file contents):
Revision 1.317 by root, Sun Sep 25 16:30:50 2022 UTC vs.
Revision 1.320 by root, Tue Feb 20 06:40:23 2024 UTC

171use common::sense; 171use common::sense;
172 172
173use base 'Exporter'; 173use base 'Exporter';
174 174
175BEGIN { 175BEGIN {
176 our $VERSION = 4.79; 176 our $VERSION = 4.81;
177 177
178 our @AIO_REQ = qw(aio_sendfile aio_seek aio_read aio_write aio_open aio_close 178 our @AIO_REQ = qw(aio_sendfile aio_seek aio_read aio_write aio_open aio_close
179 aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx 179 aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx
180 aio_scandir aio_symlink aio_readlink aio_realpath aio_fcntl aio_ioctl 180 aio_scandir aio_symlink aio_readlink aio_realpath aio_fcntl aio_ioctl
181 aio_sync aio_fsync aio_syncfs aio_fdatasync aio_sync_file_range 181 aio_sync aio_fsync aio_syncfs aio_fdatasync aio_sync_file_range
413=item aio_open $pathname, $flags, $mode, $callback->($fh) 413=item aio_open $pathname, $flags, $mode, $callback->($fh)
414 414
415Asynchronously open or create a file and call the callback with a newly 415Asynchronously open or create a file and call the callback with a newly
416created filehandle for the file (or C<undef> in case of an error). 416created filehandle for the file (or C<undef> in case of an error).
417 417
418The pathname passed to C<aio_open> must be absolute. See API NOTES, above,
419for an explanation.
420
421The C<$flags> argument is a bitmask. See the C<Fcntl> module for a 418The C<$flags> argument is a bitmask. See the C<Fcntl> module for a
422list. They are the same as used by C<sysopen>. 419list. They are the same as used by C<sysopen>.
423 420
424Likewise, C<$mode> specifies the mode of the newly created file, if it 421Likewise, C<$mode> specifies the mode of the newly created file, if it
425didn't exist and C<O_CREAT> has been given, just like perl's C<sysopen>, 422didn't exist and C<O_CREAT> has been given, just like perl's C<sysopen>,
584 581
585Works almost exactly like perl's C<stat> or C<lstat> in void context. The 582Works almost exactly like perl's C<stat> or C<lstat> in void context. The
586callback will be called after the stat and the results will be available 583callback will be called after the stat and the results will be available
587using C<stat _> or C<-s _> and other tests (with the exception of C<-B> 584using C<stat _> or C<-s _> and other tests (with the exception of C<-B>
588and C<-T>). 585and C<-T>).
589
590The pathname passed to C<aio_stat> must be absolute. See API NOTES, above,
591for an explanation.
592 586
593Currently, the stats are always 64-bit-stats, i.e. instead of returning an 587Currently, the stats are always 64-bit-stats, i.e. instead of returning an
594error when stat'ing a large file, the results will be silently truncated 588error when stat'ing a large file, the results will be silently truncated
595unless perl itself is compiled with large file support. 589unless perl itself is compiled with large file support.
596 590
981 my @stat = stat $src_fh; # hmm, might block over nfs? 975 my @stat = stat $src_fh; # hmm, might block over nfs?
982 976
983 aioreq_pri $pri; 977 aioreq_pri $pri;
984 add $grp aio_open $dst, O_CREAT | O_WRONLY | O_TRUNC, 0200, sub { 978 add $grp aio_open $dst, O_CREAT | O_WRONLY | O_TRUNC, 0200, sub {
985 if (my $dst_fh = $_[0]) { 979 if (my $dst_fh = $_[0]) {
980
981 # best-effort preallocate
982 aioreq_pri $pri;
983 add $grp aio_allocate $dst_fh, IO::AIO::FALLOC_FL_KEEP_SIZE, 0, $stat[7], sub { };
984
986 aioreq_pri $pri; 985 aioreq_pri $pri;
987 add $grp aio_sendfile $dst_fh, $src_fh, 0, $stat[7], sub { 986 add $grp aio_sendfile $dst_fh, $src_fh, 0, $stat[7], sub {
988 if ($_[0] == $stat[7]) { 987 if ($_[0] == $stat[7]) {
989 $grp->result (0); 988 $grp->result (0);
990 close $src_fh; 989 close $src_fh;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines