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.312 by root, Tue Jul 27 18:46:06 2021 UTC vs.
Revision 1.313 by root, Sat Sep 4 21:21:14 2021 UTC

2061longer exceeded. 2061longer exceeded.
2062 2062
2063In other words, this setting does not enforce a queue limit, but can be 2063In other words, this setting does not enforce a queue limit, but can be
2064used to make poll functions block if the limit is exceeded. 2064used to make poll functions block if the limit is exceeded.
2065 2065
2066This is a very bad function to use in interactive programs because it 2066This is a bad function to use in interactive programs because it blocks,
2067blocks, and a bad way to reduce concurrency because it is inexact: Better 2067and a bad way to reduce concurrency because it is inexact. If you need to
2068issue many requests without being able to call a poll function on demand,
2068use an C<aio_group> together with a feed callback. 2069it is better to use an C<aio_group> together with a feed callback.
2069 2070
2070Its main use is in scripts without an event loop - when you want to stat 2071Its main use is in scripts without an event loop - when you want to stat a
2071a lot of files, you can write something like this: 2072lot of files, you can write something like this:
2072 2073
2073 IO::AIO::max_outstanding 32; 2074 IO::AIO::max_outstanding 32;
2074 2075
2075 for my $path (...) { 2076 for my $path (...) {
2076 aio_stat $path , ...; 2077 aio_stat $path , ...;
2077 IO::AIO::poll_cb; 2078 IO::AIO::poll_cb;
2078 } 2079 }
2079 2080
2080 IO::AIO::flush; 2081 IO::AIO::flush;
2081 2082
2082The call to C<poll_cb> inside the loop will normally return instantly, but 2083The call to C<poll_cb> inside the loop will normally return instantly,
2083as soon as more thna C<32> reqeusts are in-flight, it will block until 2084allowing the loop to progress, but as soon as more than C<32> requests
2084some requests have been handled. This keeps the loop from pushing a large 2085are in-flight, it will block until some requests have been handled. This
2085number of C<aio_stat> requests onto the queue. 2086keeps the loop from pushing a large number of C<aio_stat> requests onto
2087the queue (which, with many paths to stat, can use up a lot of memory).
2086 2088
2087The default value for C<max_outstanding> is very large, so there is no 2089The default value for C<max_outstanding> is very large, so there is no
2088practical limit on the number of outstanding requests. 2090practical limit on the number of outstanding requests.
2089 2091
2090=back 2092=back

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines