… | |
… | |
171 | aio_unlink $pathname, $callback->($status) |
171 | aio_unlink $pathname, $callback->($status) |
172 | aio_mknod $pathname, $mode, $dev, $callback->($status) |
172 | aio_mknod $pathname, $mode, $dev, $callback->($status) |
173 | aio_link $srcpath, $dstpath, $callback->($status) |
173 | aio_link $srcpath, $dstpath, $callback->($status) |
174 | aio_symlink $srcpath, $dstpath, $callback->($status) |
174 | aio_symlink $srcpath, $dstpath, $callback->($status) |
175 | aio_readlink $pathname, $callback->($link) |
175 | aio_readlink $pathname, $callback->($link) |
176 | aio_realpath $pathname, $callback->($link) |
176 | aio_realpath $pathname, $callback->($path) |
177 | aio_rename $srcpath, $dstpath, $callback->($status) |
177 | aio_rename $srcpath, $dstpath, $callback->($status) |
178 | aio_mkdir $pathname, $mode, $callback->($status) |
178 | aio_mkdir $pathname, $mode, $callback->($status) |
179 | aio_rmdir $pathname, $callback->($status) |
179 | aio_rmdir $pathname, $callback->($status) |
180 | aio_readdir $pathname, $callback->($entries) |
180 | aio_readdir $pathname, $callback->($entries) |
181 | aio_readdirx $pathname, $flags, $callback->($entries, $flags) |
181 | aio_readdirx $pathname, $flags, $callback->($entries, $flags) |
… | |
… | |
643 | |
643 | |
644 | aio_truncate $fh_or_path, $offset, $callback->($status) |
644 | aio_truncate $fh_or_path, $offset, $callback->($status) |
645 | Works like truncate(2) or ftruncate(2). |
645 | Works like truncate(2) or ftruncate(2). |
646 | |
646 | |
647 | aio_allocate $fh, $mode, $offset, $len, $callback->($status) |
647 | aio_allocate $fh, $mode, $offset, $len, $callback->($status) |
648 | Allocates or freed disk space according to the $mode argument. See |
648 | Allocates or frees disk space according to the $mode argument. See |
649 | the linux "fallocate" docuemntation for details. |
649 | the linux "fallocate" documentation for details. |
650 | |
650 | |
651 | $mode can currently be 0 or "IO::AIO::FALLOC_FL_KEEP_SIZE" to |
651 | $mode can currently be 0 or "IO::AIO::FALLOC_FL_KEEP_SIZE" to |
652 | allocate space, or "IO::AIO::FALLOC_FL_PUNCH_HOLE | |
652 | allocate space, or "IO::AIO::FALLOC_FL_PUNCH_HOLE | |
653 | IO::AIO::FALLOC_FL_KEEP_SIZE", to deallocate a file range. |
653 | IO::AIO::FALLOC_FL_KEEP_SIZE", to deallocate a file range. |
654 | |
654 | |
… | |
… | |
1128 | aio_stat [$etcdir, "passwd"], sub { |
1128 | aio_stat [$etcdir, "passwd"], sub { |
1129 | # yay |
1129 | # yay |
1130 | }; |
1130 | }; |
1131 | }; |
1131 | }; |
1132 | |
1132 | |
1133 | That "aio_wd" is a request and not a normal function shows that creating |
1133 | The fact that "aio_wd" is a request and not a normal function shows that |
1134 | an IO::AIO::WD object is itself a potentially blocking operation, which |
1134 | creating an IO::AIO::WD object is itself a potentially blocking |
1135 | is why it is done asynchronously. |
1135 | operation, which is why it is done asynchronously. |
1136 | |
1136 | |
1137 | To stat the directory obtained with "aio_wd" above, one could write |
1137 | To stat the directory obtained with "aio_wd" above, one could write |
1138 | either of the following three request calls: |
1138 | either of the following three request calls: |
1139 | |
1139 | |
1140 | aio_lstat "/etc" , sub { ... # pathname as normal string |
1140 | aio_lstat "/etc" , sub { ... # pathname as normal string |
… | |
… | |
1518 | |
1518 | |
1519 | This is a very bad function to use in interactive programs because |
1519 | This is a very bad function to use in interactive programs because |
1520 | it blocks, and a bad way to reduce concurrency because it is |
1520 | it blocks, and a bad way to reduce concurrency because it is |
1521 | inexact: Better use an "aio_group" together with a feed callback. |
1521 | inexact: Better use an "aio_group" together with a feed callback. |
1522 | |
1522 | |
1523 | It's main use is in scripts without an event loop - when you want to |
1523 | Its main use is in scripts without an event loop - when you want to |
1524 | stat a lot of files, you can write somehting like this: |
1524 | stat a lot of files, you can write somehting like this: |
1525 | |
1525 | |
1526 | IO::AIO::max_outstanding 32; |
1526 | IO::AIO::max_outstanding 32; |
1527 | |
1527 | |
1528 | for my $path (...) { |
1528 | for my $path (...) { |
… | |
… | |
1559 | IO::AIO::npending |
1559 | IO::AIO::npending |
1560 | Returns the number of requests currently in the pending state |
1560 | Returns the number of requests currently in the pending state |
1561 | (executed, but not yet processed by poll_cb). |
1561 | (executed, but not yet processed by poll_cb). |
1562 | |
1562 | |
1563 | MISCELLANEOUS FUNCTIONS |
1563 | MISCELLANEOUS FUNCTIONS |
1564 | IO::AIO implements some functions that might be useful, but are not |
1564 | IO::AIO implements some functions that are useful when you want to use |
1565 | asynchronous. |
1565 | some "Advanced I/O" function not available to in Perl, without going the |
|
|
1566 | "Asynchronous I/O" route. Many of these have an asynchronous "aio_*" |
|
|
1567 | counterpart. |
1566 | |
1568 | |
1567 | IO::AIO::sendfile $ofh, $ifh, $offset, $count |
1569 | IO::AIO::sendfile $ofh, $ifh, $offset, $count |
1568 | Calls the "eio_sendfile_sync" function, which is like |
1570 | Calls the "eio_sendfile_sync" function, which is like |
1569 | "aio_sendfile", but is blocking (this makes most sense if you know |
1571 | "aio_sendfile", but is blocking (this makes most sense if you know |
1570 | the input data is likely cached already and the output filehandle is |
1572 | the input data is likely cached already and the output filehandle is |
… | |
… | |
1678 | "IO::AIO::SPLICE_F_MORE" and "IO::AIO::SPLICE_F_GIFT". |
1680 | "IO::AIO::SPLICE_F_MORE" and "IO::AIO::SPLICE_F_GIFT". |
1679 | |
1681 | |
1680 | See the splice(2) manpage for details. |
1682 | See the splice(2) manpage for details. |
1681 | |
1683 | |
1682 | IO::AIO::tee $r_fh, $w_fh, $length, $flags |
1684 | IO::AIO::tee $r_fh, $w_fh, $length, $flags |
1683 | Calls the GNU/Linux tee(2) syscall, see it's manpage and the |
1685 | Calls the GNU/Linux tee(2) syscall, see its manpage and the |
1684 | description for "IO::AIO::splice" above for details. |
1686 | description for "IO::AIO::splice" above for details. |
1685 | |
1687 | |
1686 | $actual_size = IO::AIO::pipesize $r_fh[, $new_size] |
1688 | $actual_size = IO::AIO::pipesize $r_fh[, $new_size] |
1687 | Attempts to query or change the pipe buffer size. Obviously works |
1689 | Attempts to query or change the pipe buffer size. Obviously works |
1688 | only on pipes, and currently works only on GNU/Linux systems, and |
1690 | only on pipes, and currently works only on GNU/Linux systems, and |