--- IO-AIO/AIO.pm 2008/07/15 10:42:26 1.131 +++ IO-AIO/AIO.pm 2008/10/22 18:15:36 1.142 @@ -195,12 +195,12 @@ use base 'Exporter'; BEGIN { - our $VERSION = '3.06'; + our $VERSION = '3.16'; 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_scandir aio_symlink aio_readlink aio_sync aio_fsync - aio_fdatasync aio_pathsync aio_readahead + 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); @@ -226,7 +226,7 @@ and they all accept an additional (and optional) C<$callback> argument which must be a code reference. This code reference will get called with the syscall return code (e.g. most syscalls return C<-1> on error, unlike -perl, which usually delivers "false") as it's sole argument when the given +perl, which usually delivers "false") as its sole argument after the given syscall has been executed asynchronously. All functions expecting a filehandle keep a copy of the filehandle @@ -250,7 +250,7 @@ use something else to ensure your scalar has the correct contents. This works, btw. independent of the internal UTF-8 bit, which IO::AIO -handles correctly wether it is set or not. +handles correctly whether it is set or not. =over 4 @@ -567,7 +567,7 @@ destination) from C<$srcpath> to C<$dstpath> and call the callback with the C<0> (error) or C<-1> ok. -This is a composite request that it creates the destination file with +This is a composite request that creates the destination file with mode 0200 and copies the contents of the source file into it using C, followed by restoring atime, mtime, access mode and uid/gid, in that order. @@ -633,9 +633,9 @@ destination) from C<$srcpath> to C<$dstpath> and call the callback with the C<0> (error) or C<-1> ok. -This is a composite request that tries to rename(2) the file first. If -rename files with C, it copies the file with C and, if -that is successful, unlinking the C<$srcpath>. +This is a composite request that tries to rename(2) the file first; if +rename fails with C, it copies the file with C and, if +that is successful, unlinks the C<$srcpath>. =cut @@ -857,10 +857,22 @@ If this call isn't available because your OS lacks it or it couldn't be detected, it will be emulated by calling C instead. +=item aio_sync_file_range $fh, $offset, $nbytes, $flags, $callback->($status) + +Sync the data portion of the file specified by C<$offset> and C<$length> +to disk (but NOT the metadata), by calling the Linux-specific +sync_file_range call. If sync_file_range is not available or it returns +ENOSYS, then fdatasync or fsync is being substituted. + +C<$flags> can be a combination of C, +C and +C: refer to the sync_file_range +manpage for details. + =item aio_pathsync $path, $callback->($status) This request tries to open, fsync and close the given path. This is a -composite request intended tosync directories after directory operations +composite request intended to sync directories after directory operations (E.g. rename). This might not work on all operating systems or have any specific effect, but usually it makes sure that directory changes get written to disc. It works for anything that can be opened for read-only, @@ -1015,10 +1027,11 @@ C state, they will also finish. Otherwise they will continue to exist. -That means after creating a group you have some time to add requests. And -in the callbacks of those requests, you can add further requests to the -group. And only when all those requests have finished will the the group -itself finish. +That means after creating a group you have some time to add requests +(precisely before the callback has been invoked, which is only done within +the C). And in the callbacks of those requests, you can add +further requests to the group. And only when all those requests have +finished will the the group itself finish. =over 4 @@ -1061,9 +1074,9 @@ Sets a feeder/generator on this group: every group can have an attached generator that generates requests if idle. The idea behind this is that, although you could just queue as many requests as you want in a group, -this might starve other requests for a potentially long time. For -example, C might generate hundreds of thousands C -requests, delaying any later requests for a long time. +this might starve other requests for a potentially long time. For example, +C might generate hundreds of thousands C requests, +delaying any later requests for a long time. To avoid this, and allow incremental generation of requests, you can instead a group and set a feeder on it that generates those requests. The @@ -1077,7 +1090,8 @@ If the feed does not queue more requests when called, it will be automatically removed from the group. -If the feed limit is C<0>, it will be set to C<2> automatically. +If the feed limit is C<0> when this method is called, it will be set to +C<2> automatically. Example: @@ -1099,6 +1113,9 @@ Setting the limit to C<0> will pause the feeding process. +The default value for the limit is C<0>, but note that setting a feeder +automatically bumps it up to C<2>. + =back =head2 SUPPORT FUNCTIONS