Linux-AIO
view release on metacpan or search on metacpan
readahead() populates the page cache with data from a file so that
subsequent reads from that file will not block on disk I/O. The C<$offset>
argument specifies the starting point from which data is to be read and
C<$length> specifies the number of bytes to be read. I/O is performed in
whole pages, so that offset is effectively rounded down to a page boundary
and bytes are read up to the next page boundary greater than or equal to
(off-set+length). aio_readahead() does not read beyond the end of the
file. The current file offset of the file is left unchanged.
=item aio_stat $fh_or_path, $callback
=item aio_lstat $fh, $callback
Works like perl's C<stat> or C<lstat> in void context. The callback will
be called after the stat and the results will be available using C<stat _>
or C<-s _> etc...
The pathname passed to C<aio_stat> must be absolute. See API NOTES, above,
for an explanation.
Currently, the stats are always 64-bit-stats, i.e. instead of returning an
error when stat'ing a large file, the results will be silently truncated
unless perl itself is compiled with large file support.
Example: Print the length of F</etc/passwd>:
aio_stat "/etc/passwd", sub {
$_[0] and die "stat failed: $!";
print "size is ", -s _, "\n";
};
=item aio_unlink $pathname, $callback
Asynchronously unlink (delete) a file and call the callback with the
result code.
=item aio_fsync $fh, $callback
Asynchronously call fsync on the given filehandle and call the callback
with the fsync result code.
=item aio_fdatasync $fh, $callback
Asynchronously call fdatasync on the given filehandle and call the
callback with the fdatasync result code.
=cut
min_parallel 1;
END {
max_parallel 0;
}
1;
=back
=head1 BUGS
This module has been extensively tested in a large and very busy webserver
for many years now.
- aio_open gives a fd, but all other functions expect a perl filehandle.
=head1 SEE ALSO
L<Coro>, L<IO::AIO>.
=head1 AUTHOR
Marc Lehmann <schmorp@schmorp.de>
http://home.schmorp.de/
=cut
( run in 0.603 second using v1.01-cache-2.11-cpan-39bf76dae61 )