… | |
… | |
277 | IO::AIO::idle_timeout $seconds |
277 | IO::AIO::idle_timeout $seconds |
278 | IO::AIO::max_outstanding $maxreqs |
278 | IO::AIO::max_outstanding $maxreqs |
279 | IO::AIO::nreqs |
279 | IO::AIO::nreqs |
280 | IO::AIO::nready |
280 | IO::AIO::nready |
281 | IO::AIO::npending |
281 | IO::AIO::npending |
|
|
282 | IO::AIO::min_fdlimit $nfd; |
282 | |
283 | |
283 | IO::AIO::sendfile $ofh, $ifh, $offset, $count |
284 | IO::AIO::sendfile $ofh, $ifh, $offset, $count |
284 | IO::AIO::fadvise $fh, $offset, $len, $advice |
285 | IO::AIO::fadvise $fh, $offset, $len, $advice |
285 | IO::AIO::mmap $scalar, $length, $prot, $flags[, $fh[, $offset]] |
286 | IO::AIO::mmap $scalar, $length, $prot, $flags[, $fh[, $offset]] |
286 | IO::AIO::munmap $scalar |
287 | IO::AIO::munmap $scalar |
… | |
… | |
958 | |
959 | |
959 | Try to copy the I<file> (directories not supported as either source or |
960 | Try to copy the I<file> (directories not supported as either source or |
960 | destination) from C<$srcpath> to C<$dstpath> and call the callback with |
961 | destination) from C<$srcpath> to C<$dstpath> and call the callback with |
961 | a status of C<0> (ok) or C<-1> (error, see C<$!>). |
962 | a status of C<0> (ok) or C<-1> (error, see C<$!>). |
962 | |
963 | |
|
|
964 | Existing destination files will be truncated. |
|
|
965 | |
963 | This is a composite request that creates the destination file with |
966 | This is a composite request that creates the destination file with |
964 | mode 0200 and copies the contents of the source file into it using |
967 | mode 0200 and copies the contents of the source file into it using |
965 | C<aio_sendfile>, followed by restoring atime, mtime, access mode and |
968 | C<aio_sendfile>, followed by restoring atime, mtime, access mode and |
966 | uid/gid, in that order. |
969 | uid/gid, in that order. |
967 | |
970 | |
… | |
… | |
1076 | Scans a directory (similar to C<aio_readdir>) but additionally tries to |
1079 | Scans a directory (similar to C<aio_readdir>) but additionally tries to |
1077 | efficiently separate the entries of directory C<$path> into two sets of |
1080 | efficiently separate the entries of directory C<$path> into two sets of |
1078 | names, directories you can recurse into (directories), and ones you cannot |
1081 | names, directories you can recurse into (directories), and ones you cannot |
1079 | recurse into (everything else, including symlinks to directories). |
1082 | recurse into (everything else, including symlinks to directories). |
1080 | |
1083 | |
1081 | C<aio_scandir> is a composite request that creates of many sub requests_ |
1084 | C<aio_scandir> is a composite request that generates many sub requests. |
1082 | C<$maxreq> specifies the maximum number of outstanding aio requests that |
1085 | C<$maxreq> specifies the maximum number of outstanding aio requests that |
1083 | this function generates. If it is C<< <= 0 >>, then a suitable default |
1086 | this function generates. If it is C<< <= 0 >>, then a suitable default |
1084 | will be chosen (currently 4). |
1087 | will be chosen (currently 4). |
1085 | |
1088 | |
1086 | On error, the callback is called without arguments, otherwise it receives |
1089 | On error, the callback is called without arguments, otherwise it receives |
… | |
… | |
1605 | There are some caveats: when directories get renamed (or deleted), the |
1608 | There are some caveats: when directories get renamed (or deleted), the |
1606 | pathname string doesn't change, so will point to the new directory (or |
1609 | pathname string doesn't change, so will point to the new directory (or |
1607 | nowhere at all), while the directory fd, if available on the system, |
1610 | nowhere at all), while the directory fd, if available on the system, |
1608 | will still point to the original directory. Most functions accepting a |
1611 | will still point to the original directory. Most functions accepting a |
1609 | pathname will use the directory fd on newer systems, and the string on |
1612 | pathname will use the directory fd on newer systems, and the string on |
1610 | older systems. Some functions (such as realpath) will always rely on the |
1613 | older systems. Some functions (such as C<aio_realpath>) will always rely on |
1611 | string form of the pathname. |
1614 | the string form of the pathname. |
1612 | |
1615 | |
1613 | So this functionality is mainly useful to get some protection against |
1616 | So this functionality is mainly useful to get some protection against |
1614 | C<chdir>, to easily get an absolute path out of a relative path for future |
1617 | C<chdir>, to easily get an absolute path out of a relative path for future |
1615 | reference, and to speed up doing many operations in the same directory |
1618 | reference, and to speed up doing many operations in the same directory |
1616 | (e.g. when stat'ing all files in a directory). |
1619 | (e.g. when stat'ing all files in a directory). |
… | |
… | |
2008 | This is a very bad function to use in interactive programs because it |
2011 | This is a very bad function to use in interactive programs because it |
2009 | blocks, and a bad way to reduce concurrency because it is inexact: Better |
2012 | blocks, and a bad way to reduce concurrency because it is inexact: Better |
2010 | use an C<aio_group> together with a feed callback. |
2013 | use an C<aio_group> together with a feed callback. |
2011 | |
2014 | |
2012 | Its main use is in scripts without an event loop - when you want to stat |
2015 | Its main use is in scripts without an event loop - when you want to stat |
2013 | a lot of files, you can write somehting like this: |
2016 | a lot of files, you can write something like this: |
2014 | |
2017 | |
2015 | IO::AIO::max_outstanding 32; |
2018 | IO::AIO::max_outstanding 32; |
2016 | |
2019 | |
2017 | for my $path (...) { |
2020 | for my $path (...) { |
2018 | aio_stat $path , ...; |
2021 | aio_stat $path , ...; |
… | |
… | |
2063 | some "Advanced I/O" function not available to in Perl, without going the |
2066 | some "Advanced I/O" function not available to in Perl, without going the |
2064 | "Asynchronous I/O" route. Many of these have an asynchronous C<aio_*> |
2067 | "Asynchronous I/O" route. Many of these have an asynchronous C<aio_*> |
2065 | counterpart. |
2068 | counterpart. |
2066 | |
2069 | |
2067 | =over 4 |
2070 | =over 4 |
|
|
2071 | |
|
|
2072 | =item $numfd = IO::AIO::get_fdlimit |
|
|
2073 | |
|
|
2074 | Tries to find the current file descriptor limit and returns it, or |
|
|
2075 | C<undef> and sets C<$!> in case of an error. The limit is one larger than |
|
|
2076 | the highest valid file descriptor number. |
|
|
2077 | |
|
|
2078 | =item IO::AIO::min_fdlimit [$numfd] |
|
|
2079 | |
|
|
2080 | Try to increase the current file descriptor limit(s) to at least C<$numfd> |
|
|
2081 | by changing the soft or hard file descriptor resource limit. If C<$numfd> |
|
|
2082 | is missing, it will try to set a very high limit, although this is not |
|
|
2083 | recommended when you know the actual minimum that you require. |
|
|
2084 | |
|
|
2085 | If the limit cannot be raised enough, the function makes a best-effort |
|
|
2086 | attempt to increase the limit as much as possible, using various |
|
|
2087 | tricks, while still failing. You can query the resulting limit using |
|
|
2088 | C<IO::AIO::get_fdlimit>. |
|
|
2089 | |
|
|
2090 | If an error occurs, returns C<undef> and sets C<$!>, otherwise returns |
|
|
2091 | true. |
2068 | |
2092 | |
2069 | =item IO::AIO::sendfile $ofh, $ifh, $offset, $count |
2093 | =item IO::AIO::sendfile $ofh, $ifh, $offset, $count |
2070 | |
2094 | |
2071 | Calls the C<eio_sendfile_sync> function, which is like C<aio_sendfile>, |
2095 | Calls the C<eio_sendfile_sync> function, which is like C<aio_sendfile>, |
2072 | but is blocking (this makes most sense if you know the input data is |
2096 | but is blocking (this makes most sense if you know the input data is |