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.74 by root, Tue Oct 24 17:22:17 2006 UTC vs.
Revision 1.77 by root, Wed Oct 25 17:57:30 2006 UTC

134 aio_lstat aio_unlink aio_rmdir aio_readdir aio_scandir aio_symlink 134 aio_lstat aio_unlink aio_rmdir aio_readdir aio_scandir aio_symlink
135 aio_fsync aio_fdatasync aio_readahead aio_rename aio_link aio_move 135 aio_fsync aio_fdatasync aio_readahead aio_rename aio_link aio_move
136 aio_group aio_nop); 136 aio_group aio_nop);
137 our @EXPORT = (@AIO_REQ, qw(aioreq_pri aioreq_nice)); 137 our @EXPORT = (@AIO_REQ, qw(aioreq_pri aioreq_nice));
138 our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush 138 our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush
139 min_parallel max_parallel max_outstanding nreqs); 139 min_parallel max_parallel nreqs);
140 140
141 @IO::AIO::GRP::ISA = 'IO::AIO::REQ'; 141 @IO::AIO::GRP::ISA = 'IO::AIO::REQ';
142 142
143 require XSLoader; 143 require XSLoader;
144 XSLoader::load ("IO::AIO", $VERSION); 144 XSLoader::load ("IO::AIO", $VERSION);
426with the filenames. 426with the filenames.
427 427
428=item aio_scandir $path, $maxreq, $callback->($dirs, $nondirs) 428=item aio_scandir $path, $maxreq, $callback->($dirs, $nondirs)
429 429
430Scans a directory (similar to C<aio_readdir>) but additionally tries to 430Scans a directory (similar to C<aio_readdir>) but additionally tries to
431separate the entries of directory C<$path> into two sets of names, ones 431efficiently separate the entries of directory C<$path> into two sets of
432you can recurse into (directories or links to them), and ones you cannot 432names, directories you can recurse into (directories), and ones you cannot
433recurse into (everything else). 433recurse into (everything else, including symlinks to directories).
434 434
435C<aio_scandir> is a composite request that creates of many sub requests_ 435C<aio_scandir> is a composite request that creates of many sub requests_
436C<$maxreq> specifies the maximum number of outstanding aio requests that 436C<$maxreq> specifies the maximum number of outstanding aio requests that
437this function generates. If it is C<< <= 0 >>, then a suitable default 437this function generates. If it is C<< <= 0 >>, then a suitable default
438will be chosen (currently 6). 438will be chosen (currently 6).
538 # need to check for real directory 538 # need to check for real directory
539 add $statgrp aio_lstat "$path/$entry", sub { 539 add $statgrp aio_lstat "$path/$entry", sub {
540 if (-d _) { 540 if (-d _) {
541 push @dirs, $entry; 541 push @dirs, $entry;
542 542
543 if (!--$ndirs) { 543 unless (--$ndirs) {
544 push @nondirs, @$entries; 544 push @nondirs, @$entries;
545 $statgrp->cancel_subs; 545 feed $statgrp;
546 } 546 }
547 } else { 547 } else {
548 push @nondirs, $entry; 548 push @nondirs, $entry;
549 } 549 }
550 } 550 }
682=item * They can also can also be added to other IO::AIO::GRP objects. 682=item * They can also can also be added to other IO::AIO::GRP objects.
683 683
684=item * You must not add requests to a group from within the group callback (or 684=item * You must not add requests to a group from within the group callback (or
685any later time). 685any later time).
686 686
687=item * This does not harmonise well with C<max_outstanding>, so best do
688not combine C<aio_group> with it. Groups and feeders are recommended for
689this kind of concurrency-limiting.
690
691=back 687=back
692 688
693Their lifetime, simplified, looks like this: when they are empty, they 689Their lifetime, simplified, looks like this: when they are empty, they
694will finish very quickly. If they contain only requests that are in the 690will finish very quickly. If they contain only requests that are in the
695C<done> state, they will also finish. Otherwise they will continue to 691C<done> state, they will also finish. Otherwise they will continue to
861 857
862Under normal circumstances you don't need to call this function. 858Under normal circumstances you don't need to call this function.
863 859
864=item $oldnreqs = IO::AIO::max_outstanding $nreqs 860=item $oldnreqs = IO::AIO::max_outstanding $nreqs
865 861
866[DEPRECATED] 862[REMOVED]
867 863
864Pre-2.x versions used max_outstanding for a crude request queue length limit.
865
866In 2.x+ you are advised to use a group and a feeder to limit
867concurrency. The max_outstanding feature ran very unstable (endless
868recursions causing segfaults, bad interaction with groups etc.) and was
869removed.
870
871I am deeply sorry, but I am still on the hunt for a good limiting interface.
872
873Original description was as follows:
874
868Sets the maximum number of outstanding requests to C<$nreqs>. If you 875Sets the maximum number of outstanding requests to C<$nreqs>. If you try
869try to queue up more than this number of requests, the caller will block until 876to queue up more than this number of requests, the caller will block until
870some requests have been handled. 877some requests have been handled.
871
872The default is very large, so normally there is no practical limit. If you
873queue up many requests in a loop it often improves speed if you set
874this to a relatively low number, such as C<100>.
875
876This function does not work well together with C<aio_group>'s, and their
877feeder interface is better suited to limiting concurrency, so do not use
878this function.
879
880Under normal circumstances you don't need to call this function.
881 878
882=back 879=back
883 880
884=cut 881=cut
885 882

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines