--- IO-AIO/AIO.pm 2009/11/30 22:22:13 1.168 +++ IO-AIO/AIO.pm 2010/01/10 20:28:43 1.174 @@ -193,7 +193,7 @@ use base 'Exporter'; BEGIN { - our $VERSION = '3.31'; + our $VERSION = '3.5'; our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx @@ -201,7 +201,8 @@ aio_fdatasync aio_sync_file_range aio_pathsync aio_readahead aio_rename aio_link aio_move aio_copy aio_group aio_nop aio_mknod aio_load aio_rmtree aio_mkdir aio_chown - aio_chmod aio_utime aio_truncate); + aio_chmod aio_utime aio_truncate + aio_msync aio_mtouch aio_statvfs); our @EXPORT = (@AIO_REQ, qw(aioreq_pri aioreq_nice)); our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush @@ -382,9 +383,10 @@ zero-copy operation. For this to work, C<$out_fh> should refer to a socket, and C<$in_fh> should refer to mmap'able file. -If the native sendfile call fails or is not implemented, it will be -emulated, so you can call C on any type of filehandle -regardless of the limitations of the operating system. +If a native sendfile cannot be found or it fails with C, +C, C, C, C or C, +it will be emulated, so you can call C on any type of +filehandle regardless of the limitations of the operating system. Please note, however, that C can read more bytes from C<$in_fh> than are written, and there is no way to find out how many @@ -432,6 +434,51 @@ }; +=item aio_statvfs $fh_or_path, $callback->($statvfs) + +Works like the POSIX C or C syscalls, depending on +whether a file handle or path was passed. + +On success, the callback is passed a hash reference with the following +members: C, C, C, C, C, C, +C, C, C, C and C. On failure, C +is passed. + +The following POSIX IO::AIO::ST_* constants are defined: C and +C. + +The following non-POSIX IO::AIO::ST_* flag masks are defined to +their correct value when available, or to C<0> on systems that do +not support them: C, C, C, +C, C, C, C, C, +C and C. + +Example: stat C and dump out the data if successful. + + aio_statvfs "/wd", sub { + my $f = $_[0] + or die "statvfs: $!"; + + use Data::Dumper; + say Dumper $f; + }; + + # result: + { + bsize => 1024, + bfree => 4333064312, + blocks => 10253828096, + files => 2050765568, + flag => 4096, + favail => 2042092649, + bavail => 4333064312, + ffree => 2042092649, + namemax => 255, + frsize => 1024, + fsid => 1810 + } + + =item aio_utime $fh_or_path, $atime, $mtime, $callback->($status) Works like perl's C function (including the special case of $atime @@ -991,6 +1038,32 @@ $grp } +=item aio_msync $scalar, $offset = 0, $length = undef, flags = 0, $callback->($status) + +This is a rather advanced IO::AIO call, which only works on mmap(2)ed +scalars (see the L or L modules for details on this, note +that the scalar must only be modified in-place while an aio operation is +pending on it). + +It calls the C function of your OS, if available, with the memory +area starting at C<$offset> in the string and ending C<$length> bytes +later. If C<$length> is negative, counts from the end, and if C<$length> +is C, then it goes till the end of the string. The flags can be +a combination of C, C and +C. + +=item aio_mtouch $scalar, $offset = 0, $length = undef, flags = 0, $callback->($status) + +This is a rather advanced IO::AIO call, which works best on mmap(2)ed +scalars. + +It touches (reads or writes) all memory pages in the specified +range inside the scalar. All caveats and parameters are the same +as for C, above, except for flags, which must be either +C<0> (which reads all pages and ensures they are instantiated) or +C, which modifies the memory page s(by reading and +writing an octet from it, which dirties the page). + =item aio_group $callback->(...) This is a very special aio request: Instead of doing something, it is a @@ -1429,6 +1502,21 @@ On systems that do not implement C, this function returns ENOSYS, otherwise the return value of C. +=item IO::AIO::mlockall $flags + +Calls the C function with the given C<$flags> (a combination of +C and C). + +On systems that do not implement C, this function returns +ENOSYS, otherwise the return value of C. + +=item IO::AIO::munlockall + +Calls the C function. + +On systems that do not implement C, this function returns +ENOSYS, otherwise the return value of C. + =back =cut