Linux-AIO
view release on metacpan or search on metacpan
into the scalar given by "data" and offset "dataoffset" and calls
the callback without the actual number of bytes read (or -1 on
error, just like the syscall).
Example: Read 15 bytes at offset 7 into scalar $buffer, strating at
offset 0 within the scalar:
aio_read $fh, 7, 15, $buffer, 0, sub {
$_[0] >= 0 or die "read error: $!";
print "read <$buffer>\n";
};
aio_readahead $fh,$offset,$length, $callback
Asynchronously reads the specified byte range into the page cache,
using the "readahead" syscall.
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
$offset argument specifies the starting point from which data is to
be read and $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.
aio_stat $fh_or_path, $callback
aio_lstat $fh, $callback
Works like perl's "stat" or "lstat" in void context. The callback
will be called after the stat and the results will be available
using "stat _" or "-s _" etc...
The pathname passed to "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 /etc/passwd:
aio_stat "/etc/passwd", sub {
$_[0] and die "stat failed: $!";
print "size is ", -s _, "\n";
};
aio_unlink $pathname, $callback
Asynchronously unlink (delete) a file and call the callback with the
result code.
aio_fsync $fh, $callback
Asynchronously call fsync on the given filehandle and call the
callback with the fsync result code.
aio_fdatasync $fh, $callback
Asynchronously call fdatasync on the given filehandle and call the
callback with the fdatasync result code.
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.
SEE ALSO
Coro, IO::AIO.
AUTHOR
Marc Lehmann <schmorp@schmorp.de>
http://home.schmorp.de/
( run in 1.149 second using v1.01-cache-2.11-cpan-39bf76dae61 )