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.136 by root, Tue Sep 30 14:07:59 2008 UTC vs.
Revision 1.141 by root, Wed Oct 22 16:30:49 2008 UTC

193use strict 'vars'; 193use strict 'vars';
194 194
195use base 'Exporter'; 195use base 'Exporter';
196 196
197BEGIN { 197BEGIN {
198 our $VERSION = '3.1'; 198 our $VERSION = '3.16';
199 199
200 our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close 200 our @AIO_REQ = qw(aio_sendfile aio_read aio_write aio_open aio_close
201 aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir 201 aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir
202 aio_scandir aio_symlink aio_readlink aio_sync aio_fsync 202 aio_scandir aio_symlink aio_readlink aio_sync aio_fsync
203 aio_fdatasync aio_pathsync aio_readahead 203 aio_fdatasync aio_pathsync aio_readahead
631 631
632Try to move the I<file> (directories not supported as either source or 632Try to move the I<file> (directories not supported as either source or
633destination) from C<$srcpath> to C<$dstpath> and call the callback with 633destination) from C<$srcpath> to C<$dstpath> and call the callback with
634the C<0> (error) or C<-1> ok. 634the C<0> (error) or C<-1> ok.
635 635
636This is a composite request that tries to rename(2) the file first. If 636This is a composite request that tries to rename(2) the file first; if
637rename files with C<EXDEV>, it copies the file with C<aio_copy> and, if 637rename fails with C<EXDEV>, it copies the file with C<aio_copy> and, if
638that is successful, unlinking the C<$srcpath>. 638that is successful, unlinks the C<$srcpath>.
639 639
640=cut 640=cut
641 641
642sub aio_move($$;$) { 642sub aio_move($$;$) {
643 my ($src, $dst, $cb) = @_; 643 my ($src, $dst, $cb) = @_;
1060=item feed $grp $callback->($grp) 1060=item feed $grp $callback->($grp)
1061 1061
1062Sets a feeder/generator on this group: every group can have an attached 1062Sets a feeder/generator on this group: every group can have an attached
1063generator that generates requests if idle. The idea behind this is that, 1063generator that generates requests if idle. The idea behind this is that,
1064although you could just queue as many requests as you want in a group, 1064although you could just queue as many requests as you want in a group,
1065this might starve other requests for a potentially long time. For 1065this might starve other requests for a potentially long time. For example,
1066example, C<aio_scandir> might generate hundreds of thousands C<aio_stat> 1066C<aio_scandir> might generate hundreds of thousands C<aio_stat> requests,
1067requests, delaying any later requests for a long time. 1067delaying any later requests for a long time.
1068 1068
1069To avoid this, and allow incremental generation of requests, you can 1069To avoid this, and allow incremental generation of requests, you can
1070instead a group and set a feeder on it that generates those requests. The 1070instead a group and set a feeder on it that generates those requests. The
1071feed callback will be called whenever there are few enough (see C<limit>, 1071feed callback will be called whenever there are few enough (see C<limit>,
1072below) requests active in the group itself and is expected to queue more 1072below) requests active in the group itself and is expected to queue more
1076not impose any limits). 1076not impose any limits).
1077 1077
1078If the feed does not queue more requests when called, it will be 1078If the feed does not queue more requests when called, it will be
1079automatically removed from the group. 1079automatically removed from the group.
1080 1080
1081If the feed limit is C<0>, it will be set to C<2> automatically. 1081If the feed limit is C<0> when this method is called, it will be set to
1082C<2> automatically.
1082 1083
1083Example: 1084Example:
1084 1085
1085 # stat all files in @files, but only ever use four aio requests concurrently: 1086 # stat all files in @files, but only ever use four aio requests concurrently:
1086 1087
1097 1098
1098Sets the feeder limit for the group: The feeder will be called whenever 1099Sets the feeder limit for the group: The feeder will be called whenever
1099the group contains less than this many requests. 1100the group contains less than this many requests.
1100 1101
1101Setting the limit to C<0> will pause the feeding process. 1102Setting the limit to C<0> will pause the feeding process.
1103
1104The default value for the limit is C<0>, but note that setting a feeder
1105automatically bumps it up to C<2>.
1102 1106
1103=back 1107=back
1104 1108
1105=head2 SUPPORT FUNCTIONS 1109=head2 SUPPORT FUNCTIONS
1106 1110

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines