… | |
… | |
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 |
… | |
… | |
740 | C<$mode> is usually C<0> or C<IO::AIO::FALLOC_FL_KEEP_SIZE> to allocate |
741 | C<$mode> is usually C<0> or C<IO::AIO::FALLOC_FL_KEEP_SIZE> to allocate |
741 | space, or C<IO::AIO::FALLOC_FL_PUNCH_HOLE | IO::AIO::FALLOC_FL_KEEP_SIZE>, |
742 | space, or C<IO::AIO::FALLOC_FL_PUNCH_HOLE | IO::AIO::FALLOC_FL_KEEP_SIZE>, |
742 | to deallocate a file range. |
743 | to deallocate a file range. |
743 | |
744 | |
744 | IO::AIO also supports C<FALLOC_FL_COLLAPSE_RANGE>, to remove a range |
745 | IO::AIO also supports C<FALLOC_FL_COLLAPSE_RANGE>, to remove a range |
745 | (without leaving a hole) and C<FALLOC_FL_ZERO_RANGE>, to zero a range (see |
746 | (without leaving a hole), C<FALLOC_FL_ZERO_RANGE>, to zero a range, |
746 | your L<fallocate(2)> manpage). |
747 | C<FALLOC_FL_INSERT_RANGE> to insert a range and C<FALLOC_FL_UNSHARE_RANGE> |
|
|
748 | to unshare shared blocks (see your L<fallocate(2)> manpage). |
747 | |
749 | |
748 | The file system block size used by C<fallocate> is presumably the |
750 | The file system block size used by C<fallocate> is presumably the |
749 | C<f_bsize> returned by C<statvfs>. |
751 | C<f_bsize> returned by C<statvfs>, but different filesystems and filetypes |
|
|
752 | can dictate other limitations. |
750 | |
753 | |
751 | If C<fallocate> isn't available or cannot be emulated (currently no |
754 | If C<fallocate> isn't available or cannot be emulated (currently no |
752 | emulation will be attempted), passes C<-1> and sets C<$!> to C<ENOSYS>. |
755 | emulation will be attempted), passes C<-1> and sets C<$!> to C<ENOSYS>. |
753 | |
756 | |
754 | |
757 | |
… | |
… | |
955 | =item aio_copy $srcpath, $dstpath, $callback->($status) |
958 | =item aio_copy $srcpath, $dstpath, $callback->($status) |
956 | |
959 | |
957 | 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 |
958 | 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 |
959 | 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<$!>). |
|
|
963 | |
|
|
964 | Existing destination files will be truncated. |
960 | |
965 | |
961 | This is a composite request that creates the destination file with |
966 | This is a composite request that creates the destination file with |
962 | 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 |
963 | C<aio_sendfile>, followed by restoring atime, mtime, access mode and |
968 | C<aio_sendfile>, followed by restoring atime, mtime, access mode and |
964 | uid/gid, in that order. |
969 | uid/gid, in that order. |
… | |
… | |
2006 | 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 |
2007 | 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 |
2008 | use an C<aio_group> together with a feed callback. |
2013 | use an C<aio_group> together with a feed callback. |
2009 | |
2014 | |
2010 | 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 |
2011 | a lot of files, you can write somehting like this: |
2016 | a lot of files, you can write something like this: |
2012 | |
2017 | |
2013 | IO::AIO::max_outstanding 32; |
2018 | IO::AIO::max_outstanding 32; |
2014 | |
2019 | |
2015 | for my $path (...) { |
2020 | for my $path (...) { |
2016 | aio_stat $path , ...; |
2021 | aio_stat $path , ...; |
… | |
… | |
2061 | 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 |
2062 | "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_*> |
2063 | counterpart. |
2068 | counterpart. |
2064 | |
2069 | |
2065 | =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<$!>. |
2066 | |
2091 | |
2067 | =item IO::AIO::sendfile $ofh, $ifh, $offset, $count |
2092 | =item IO::AIO::sendfile $ofh, $ifh, $offset, $count |
2068 | |
2093 | |
2069 | Calls the C<eio_sendfile_sync> function, which is like C<aio_sendfile>, |
2094 | Calls the C<eio_sendfile_sync> function, which is like C<aio_sendfile>, |
2070 | but is blocking (this makes most sense if you know the input data is |
2095 | but is blocking (this makes most sense if you know the input data is |