… | |
… | |
171 | use common::sense; |
171 | use common::sense; |
172 | |
172 | |
173 | use base 'Exporter'; |
173 | use base 'Exporter'; |
174 | |
174 | |
175 | BEGIN { |
175 | BEGIN { |
176 | our $VERSION = 4.4; |
176 | our $VERSION = 4.42; |
177 | |
177 | |
178 | our @AIO_REQ = qw(aio_sendfile aio_seek aio_read aio_write aio_open aio_close |
178 | our @AIO_REQ = qw(aio_sendfile aio_seek aio_read aio_write aio_open aio_close |
179 | aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx |
179 | aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx |
180 | aio_scandir aio_symlink aio_readlink aio_realpath aio_fcntl aio_ioctl |
180 | aio_scandir aio_symlink aio_readlink aio_realpath aio_fcntl aio_ioctl |
181 | aio_sync aio_fsync aio_syncfs aio_fdatasync aio_sync_file_range |
181 | aio_sync aio_fsync aio_syncfs aio_fdatasync aio_sync_file_range |
… | |
… | |
192 | our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush |
192 | our @EXPORT_OK = qw(poll_fileno poll_cb poll_wait flush |
193 | min_parallel max_parallel max_idle idle_timeout |
193 | min_parallel max_parallel max_idle idle_timeout |
194 | nreqs nready npending nthreads |
194 | nreqs nready npending nthreads |
195 | max_poll_time max_poll_reqs |
195 | max_poll_time max_poll_reqs |
196 | sendfile fadvise madvise |
196 | sendfile fadvise madvise |
197 | mmap munmap munlock munlockall); |
197 | mmap munmap mremap munlock munlockall); |
198 | |
198 | |
199 | push @AIO_REQ, qw(aio_busy); # not exported |
199 | push @AIO_REQ, qw(aio_busy); # not exported |
200 | |
200 | |
201 | @IO::AIO::GRP::ISA = 'IO::AIO::REQ'; |
201 | @IO::AIO::GRP::ISA = 'IO::AIO::REQ'; |
202 | |
202 | |
… | |
… | |
285 | |
285 | |
286 | IO::AIO::sendfile $ofh, $ifh, $offset, $count |
286 | IO::AIO::sendfile $ofh, $ifh, $offset, $count |
287 | IO::AIO::fadvise $fh, $offset, $len, $advice |
287 | IO::AIO::fadvise $fh, $offset, $len, $advice |
288 | IO::AIO::mmap $scalar, $length, $prot, $flags[, $fh[, $offset]] |
288 | IO::AIO::mmap $scalar, $length, $prot, $flags[, $fh[, $offset]] |
289 | IO::AIO::munmap $scalar |
289 | IO::AIO::munmap $scalar |
|
|
290 | IO::AIO::mremap $scalar, $new_length, $flags[, $new_address] |
290 | IO::AIO::madvise $scalar, $offset, $length, $advice |
291 | IO::AIO::madvise $scalar, $offset, $length, $advice |
291 | IO::AIO::mprotect $scalar, $offset, $length, $protect |
292 | IO::AIO::mprotect $scalar, $offset, $length, $protect |
292 | IO::AIO::munlock $scalar, $offset = 0, $length = undef |
293 | IO::AIO::munlock $scalar, $offset = 0, $length = undef |
293 | IO::AIO::munlockall |
294 | IO::AIO::munlockall |
294 | |
295 | |
… | |
… | |
404 | following POSIX and non-POSIX constants are available (missing ones on |
405 | following POSIX and non-POSIX constants are available (missing ones on |
405 | your system are, as usual, C<0>): |
406 | your system are, as usual, C<0>): |
406 | |
407 | |
407 | C<O_ASYNC>, C<O_DIRECT>, C<O_NOATIME>, C<O_CLOEXEC>, C<O_NOCTTY>, C<O_NOFOLLOW>, |
408 | C<O_ASYNC>, C<O_DIRECT>, C<O_NOATIME>, C<O_CLOEXEC>, C<O_NOCTTY>, C<O_NOFOLLOW>, |
408 | C<O_NONBLOCK>, C<O_EXEC>, C<O_SEARCH>, C<O_DIRECTORY>, C<O_DSYNC>, |
409 | C<O_NONBLOCK>, C<O_EXEC>, C<O_SEARCH>, C<O_DIRECTORY>, C<O_DSYNC>, |
409 | C<O_RSYNC>, C<O_SYNC>, C<O_PATH>, C<O_TMPFILE>, and C<O_TTY_INIT>. |
410 | C<O_RSYNC>, C<O_SYNC>, C<O_PATH>, C<O_TMPFILE>, C<O_TTY_INIT> and C<O_ACCMODE>. |
410 | |
411 | |
411 | |
412 | |
412 | =item aio_close $fh, $callback->($status) |
413 | =item aio_close $fh, $callback->($status) |
413 | |
414 | |
414 | Asynchronously close a file and call the callback with the result |
415 | Asynchronously close a file and call the callback with the result |
… | |
… | |
789 | |
790 | |
790 | =over 4 |
791 | =over 4 |
791 | |
792 | |
792 | =item IO::AIO::READDIR_DENTS |
793 | =item IO::AIO::READDIR_DENTS |
793 | |
794 | |
794 | When this flag is off, then the callback gets an arrayref consisting of |
795 | Normally the callback gets an arrayref consisting of names only (as |
795 | names only (as with C<aio_readdir>), otherwise it gets an arrayref with |
796 | with C<aio_readdir>). If this flag is set, then the callback gets an |
796 | C<[$name, $type, $inode]> arrayrefs, each describing a single directory |
797 | arrayref with C<[$name, $type, $inode]> arrayrefs, each describing a |
797 | entry in more detail. |
798 | single directory entry in more detail: |
798 | |
799 | |
799 | C<$name> is the name of the entry. |
800 | C<$name> is the name of the entry. |
800 | |
801 | |
801 | C<$type> is one of the C<IO::AIO::DT_xxx> constants: |
802 | C<$type> is one of the C<IO::AIO::DT_xxx> constants: |
802 | |
803 | |
803 | C<IO::AIO::DT_UNKNOWN>, C<IO::AIO::DT_FIFO>, C<IO::AIO::DT_CHR>, C<IO::AIO::DT_DIR>, |
804 | C<IO::AIO::DT_UNKNOWN>, C<IO::AIO::DT_FIFO>, C<IO::AIO::DT_CHR>, C<IO::AIO::DT_DIR>, |
804 | C<IO::AIO::DT_BLK>, C<IO::AIO::DT_REG>, C<IO::AIO::DT_LNK>, C<IO::AIO::DT_SOCK>, |
805 | C<IO::AIO::DT_BLK>, C<IO::AIO::DT_REG>, C<IO::AIO::DT_LNK>, C<IO::AIO::DT_SOCK>, |
805 | C<IO::AIO::DT_WHT>. |
806 | C<IO::AIO::DT_WHT>. |
806 | |
807 | |
807 | C<IO::AIO::DT_UNKNOWN> means just that: readdir does not know. If you need to |
808 | C<IO::AIO::DT_UNKNOWN> means just that: readdir does not know. If you need |
808 | know, you have to run stat yourself. Also, for speed reasons, the C<$type> |
809 | to know, you have to run stat yourself. Also, for speed/memory reasons, |
809 | scalars are read-only: you can not modify them. |
810 | the C<$type> scalars are read-only: you must not modify them. |
810 | |
811 | |
811 | C<$inode> is the inode number (which might not be exact on systems with 64 |
812 | C<$inode> is the inode number (which might not be exact on systems with 64 |
812 | bit inode numbers and 32 bit perls). This field has unspecified content on |
813 | bit inode numbers and 32 bit perls). This field has unspecified content on |
813 | systems that do not deliver the inode information. |
814 | systems that do not deliver the inode information. |
814 | |
815 | |
… | |
… | |
825 | short names are tried first. |
826 | short names are tried first. |
826 | |
827 | |
827 | =item IO::AIO::READDIR_STAT_ORDER |
828 | =item IO::AIO::READDIR_STAT_ORDER |
828 | |
829 | |
829 | When this flag is set, then the names will be returned in an order |
830 | When this flag is set, then the names will be returned in an order |
830 | suitable for stat()'ing each one. That is, when you plan to stat() |
831 | suitable for stat()'ing each one. That is, when you plan to stat() most or |
831 | all files in the given directory, then the returned order will likely |
832 | all files in the given directory, then the returned order will likely be |
832 | be fastest. |
833 | faster. |
833 | |
834 | |
834 | If both this flag and C<IO::AIO::READDIR_DIRS_FIRST> are specified, then |
835 | If both this flag and C<IO::AIO::READDIR_DIRS_FIRST> are specified, |
835 | the likely dirs come first, resulting in a less optimal stat order. |
836 | then the likely dirs come first, resulting in a less optimal stat order |
|
|
837 | for stat'ing all entries, but likely a more optimal order for finding |
|
|
838 | subdirectories. |
836 | |
839 | |
837 | =item IO::AIO::READDIR_FOUND_UNKNOWN |
840 | =item IO::AIO::READDIR_FOUND_UNKNOWN |
838 | |
841 | |
839 | This flag should not be set when calling C<aio_readdirx>. Instead, it |
842 | This flag should not be set when calling C<aio_readdirx>. Instead, it |
840 | is being set by C<aio_readdirx>, when any of the C<$type>'s found were |
843 | is being set by C<aio_readdirx>, when any of the C<$type>'s found were |
… | |
… | |
2156 | |
2159 | |
2157 | =item IO::AIO::munmap $scalar |
2160 | =item IO::AIO::munmap $scalar |
2158 | |
2161 | |
2159 | Removes a previous mmap and undefines the C<$scalar>. |
2162 | Removes a previous mmap and undefines the C<$scalar>. |
2160 | |
2163 | |
|
|
2164 | =item IO::AIO::mremap $scalar, $new_length, $flags = MREMAP_MAYMOVE[, $new_address = 0] |
|
|
2165 | |
|
|
2166 | Calls the Linux-specific mremap(2) system call. The C<$scalar> must have |
|
|
2167 | been mapped by C<IO::AIO::mmap>, and C<$flags> must currently either be |
|
|
2168 | C<0> or C<IO::AIO::MREMAP_MAYMOVE>. |
|
|
2169 | |
|
|
2170 | Returns true if successful, and false otherwise. If the underlying mmapped |
|
|
2171 | region has changed address, then the true value has the numerical value |
|
|
2172 | C<1>, otherwise it has the numerical value C<0>: |
|
|
2173 | |
|
|
2174 | my $success = IO::AIO::mremap $mmapped, 8192, IO::AIO::MREMAP_MAYMOVE |
|
|
2175 | or die "mremap: $!"; |
|
|
2176 | |
|
|
2177 | if ($success*1) { |
|
|
2178 | warn "scalar has chanegd address in memory\n"; |
|
|
2179 | } |
|
|
2180 | |
|
|
2181 | C<IO::AIO::MREMAP_FIXED> and the C<$new_address> argument are currently |
|
|
2182 | implemented, but not supported and might go away in a future version. |
|
|
2183 | |
|
|
2184 | On systems where this call is not supported or is not emulated, this call |
|
|
2185 | returns falls and sets C<$!> to C<ENOSYS>. |
|
|
2186 | |
2161 | =item IO::AIO::munlock $scalar, $offset = 0, $length = undef |
2187 | =item IO::AIO::munlock $scalar, $offset = 0, $length = undef |
2162 | |
2188 | |
2163 | Calls the C<munlock> function, undoing the effects of a previous |
2189 | Calls the C<munlock> function, undoing the effects of a previous |
2164 | C<aio_mlock> call (see its description for details). |
2190 | C<aio_mlock> call (see its description for details). |
2165 | |
2191 | |